- 
                Notifications
    
You must be signed in to change notification settings  - Fork 376
 
Description
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