fix(feed): add ping_interval/ping_timeout to prevent zombie WebSocket#3
Open
AkhilSharma1 wants to merge 1 commit intomarketcalls:masterfrom
Open
fix(feed): add ping_interval/ping_timeout to prevent zombie WebSocket#3AkhilSharma1 wants to merge 1 commit intomarketcalls:masterfrom
AkhilSharma1 wants to merge 1 commit intomarketcalls:masterfrom
Conversation
Without ping_interval, run_forever() never sends WebSocket pings. On unreliable connections (e.g. India VPS), the TCP socket can appear OPEN at the OS level while the broker has silently stopped streaming ticks. This is the "zombie WebSocket" problem: the client never sees an error or disconnect, so on_close never fires and reconnect logic never runs. Setting ping_interval=20 causes websocket-client to send a ping frame every 20 seconds. If the pong is not received within ping_timeout=10s, the library closes the socket and fires on_close, allowing callers to detect the drop and reconnect. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without ping_interval, run_forever() never sends WebSocket pings. On unreliable connections (e.g. India VPS), the TCP socket can appear OPEN at the OS level while the broker has silently stopped streaming ticks. This is the "zombie WebSocket" problem: the client never sees an error or disconnect, so on_close never fires and reconnect logic never runs.
Setting ping_interval=20 causes websocket-client to send a ping frame every 20 seconds. If the pong is not received within ping_timeout=10s, the library closes the socket and fires on_close, allowing callers to detect the drop and reconnect.
Summary by cubic
Add WebSocket keepalive to prevent zombie connections. We now run
websocket-clientwith ping_interval=20 and ping_timeout=10, which sends a ping every 20s and closes if no pong in 10s so on_close fires and reconnect logic runs.Written for commit 9ee86a7. Summary will update on new commits.