Skip to content

Does picows have a heartbeat mechanism? #2

@river-walras

Description

@river-walras

Some servers, like the OKX WebSocket server, require clients to send a ping message every 30 seconds:

To maintain a stable connection:

  1. Set a timer for N seconds upon receiving a response, where N is less than 30.
  2. If the timer expires without receiving a new message, send the string 'ping'.
  3. Expect a 'pong' reply. If no response is received within N seconds, raise an error or reconnect.

Similarly, the Bybit WebSocket server recommends sending a ping heartbeat every 20 seconds to prevent network or program issues.

How can this be achieved using picows? I previously used websockets, which handled this automatically. I would really appreciate it if you could provide an example of how to implement this mechanism.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions