Skip to content

Reconnection with exponential backoff #491

@chr15m

Description

@chr15m

When I was building Watch Later I had to implement reconnection with an exponential backoff.

If a relay is closing a connection it should be because it doesn't want you connected to it
(@fiatjaf on #191)

I found in practical usage devices often get disconnected from relays because of moving between networks, flaky wifi, or whatever.

I also found .onClose was not a reliable indicator of websocket connectivity. It would be useful to have some kind of optional ping/heartbeat so the client can find out as soon as the websocket becomes unreliable (e.g. packets stop going through).

This is how the ws documentation addresses it:

https://github.com/websockets/ws#how-to-detect-and-close-broken-connections

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions