Repository navigation
Python example: reconnect after drops and silence, with backoff - #31
Open
GiuseppeSaluto wants to merge 1 commit into
Open
GiuseppeSaluto wants to merge 1 commit into
GiuseppeSaluto wants to merge 1 commit into
Conversation
The example ended on the first dropped connection and could wait forever on a connection that stays open but stops delivering messages. - Iterate over websockets.connect() to open a new connection after each one ends. - Reconnect when no message arrives for SILENCE_TIMEOUT_SECONDS. - Wait before reconnecting, with exponential backoff and jitter as the documentation recommends; reset it once the subscription is confirmed. An invalid API key closes the connection right after it opens, so without the wait the client would reconnect in a tight loop. - Say so when the connection closes before the SubscriptionConfirmation, the usual sign of a wrong API key or bounding boxes.
|
@aisstream Any updates for this fix? |
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.
The Python example ends on the first dropped connection, and it can wait forever on a
connection that stays open but stops delivering messages. This change keeps it running
while staying a short, readable example.
What changes (python/main.py only)
websockets.connect(), so a new connection is opened after each one ends.SILENCE_TIMEOUT_SECONDS(120 s). I hit thisin practice: the stream stayed open but silent for about 10 minutes.
recommends, and resets the wait once the subscription is confirmed. An invalid API key
closes the connection right after it opens, so without the wait the client would
reconnect in a tight loop.
SubscriptionConfirmation, it says so andsuggests checking the API key and bounding boxes.
How I tested it