question

Lenn Dolling avatar image
Lenn Dolling asked Tyler Liu answered

[PYTHON] Timeout with websockets ConnectionClosedError: received 4300 (private use) Idle timeout expired; then sent 4300 (private use) Idle timeout expired

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)
subscriptionnotifications
1689356866193.png (253.8 KiB)
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Tyler Liu avatar image
Tyler Liu answered

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

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys