Skip to main content

I start up the websocket process to capture events from given extensions. The intention is to have a long running websocket that. However, after a bit (~10 minutes) of getting events properly, I recieve this:
  Create connection error event triggered!
  received 1000 (OK) Bye; no close frame sent
  Create connection error event triggered!
  received 1000 (OK) Bye; no close frame sent
And no more events are received. 

Here is the relevant code:

    # more callback functions above...
def create_connection_error(self, data):
print("Create connection error event triggered!")
print(data)

async def init_web_socket(self, tele_sess_callback, tele_state_callback, extensions):
self.login()
web_socket_client = self.sdk.create_web_socket_client()
web_socket_client.on(WebSocketEvents.connectionCreated, self.on_web_socket_created)
web_socket_client.on(WebSocketEvents.subscriptionCreated, self.on_subscription_created)
web_socket_client.on(WebSocketEvents.receiveSubscriptionNotification, self.on_notification)
web_socket_client.on(WebSocketEvents.createSubscriptionError, self.create_subscription_error)
web_socket_client.on(WebSocketEvents.recoverConnectionError, self.recover_connection_error)
web_socket_client.on(WebSocketEvents.createConnectionError, self.create_connection_error)
#web_socket_client.run_forever()

extension_events = self.get_events(extensions)
print("Following events added to webhook: " + str(extension_events))
await asyncio.gather(
web_socket_client.create_new_connection(),
web_socket_client.create_subscription(self.get_events(extensions))
)
print("I/O blocking web socket ended")
def start_init_web_socket_thread(self, tele_sess_callback, tele_state_callback, extensions):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

async def async_init_web_socket():
await self.init_web_socket(tele_sess_callback, tele_state_callback, extensions)

while True:
loop.run_until_complete(async_init_web_socket())
def register_call_logging(self, tele_sess_callback, tele_state_callback, extensions):
self.tele_state_callback = tele_state_callback
self.tele_sess_callback = tele_sess_callback
thread = threading.Thread(target=self.start_init_web_socket_thread, args=(tele_sess_callback, tele_state_callback, extensions, d))
thread.daemon = True # ensure process terminates when main thread completes
thread.start()

It was to my understanding that the sdk handles heart beats, and I can’t understand the createConnectionError function getting triggered, because looking at the source code of the SDK, I only see that triggered when new websockets are instantiated.

Please share your SDK version number. 

10 minutes sounds like before the heartbeat was added: https://github.com/ringcentral/ringcentral-python/commit/88fea17744751760d723b938e751a7cbb2d8e9ad


I cannot reproduce this issue. Please try https://github.com/tylerlong/rc-python-quick-start

 

I kept it running for 30 minutes and there was no issue.


Reply