Skip to content

Handling RPC Down Scenario – Infinite WebSocket Reconnection Issue #6204

@nparmar2024

Description

@nparmar2024

Hi Polkadot team,

While integrating with Polkadot RPC via WebSockets, we observed the following behavior:

When the configured RPC endpoint is down/unavailable, the client keeps trying to reconnect infinitely.

If the connection is never established, this leads to the service breaking or being stuck in a retry loop without recovery.

Expected behavior:

Ideally, the SDK should provide a configurable retry strategy (e.g., max retries, exponential backoff, or graceful failure).

Alternatively, there should be a recommended pattern for developers to handle such scenarios gracefully.

Questions:

Is there a way to configure a max retry count or timeout for WebSocket reconnections?

What’s the recommended best practice to handle this scenario so the service doesn’t hang?

Would it make sense for the SDK to expose a built-in mechanism to fail fast or fallback when RPC is not available?

Environment:

Polkadot.js API: ^16.0.1

Node.js version : v21.6.2

Runtime environment: Linux

Thanks in advance

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