Wrong Keepalive Interval Crashed a Trading Bot's WebSocket Every 5 Minutes
A developer running an algorithmic crypto trading engine discovered that their WebSocket connection to market data provider MMT was silently dropping every five to six minutes, causing gaps in live trading data. The root cause was a mismatch between the provider's idle session timeout of approximately 300 seconds and the engine's keepalive interval, which was set to fire every 10 minutes — well after the server had already closed the connection. The fix involved changing a single constant in the code, reducing the keepalive interval from 10 minutes to 4 minutes so it fires before the server's timeout threshold. The silent failure — logged only as a 1011 read_error — had initially led the developer to suspect rate limiting, memory leaks, or network instability. The incident highlights the importance of knowing a provider's idle timeout and ensuring keepalive intervals are set with a safe margin below that limit.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in