Skip to main content

Trying to setup a heartbeat to keep the Notification websocket listener app that I am developing from crashing...

1689356866193.png

I am subscribing for session events and processing them in python just after time the app will fail with the above message.


I wonder what is the best way to do this... platform.refresh?


should I re-recreate the subscription on timeout vs sending a ping?


heartbeat_interval = 30  # in seconds

async def heartbeat(platform, interval):
while True:
try:
platform.refresh()
except ConnectionClosed:
break
await asyncio.sleep(interval)

To keep it alive, you should send a websocket ping frame. This is just a low level websocket exception that has little do to with RingCentral. (RingCentral SDK should handle this case though).

Here is how JavaScript handle it, FYI: https://github.com/ringcentral/ringcentral-extensible/blob/master/packages/extensions/ws/src/index.ts#L265


Reply