Repository navigation
fix(ticker): invoke sendPing in ping loop to detect connection drops - #245
Open
AnkitaAdvitot wants to merge 1 commit into
Open
AnkitaAdvitot wants to merge 1 commit into
AnkitaAdvitot wants to merge 1 commit into
Conversation
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.
Description
Fixes #237
In
kiteconnect/ticker.py,KiteTickerClientProtocol._loop_pingwas scheduled duringonOpento maintain connection health and refresh_last_ping_time. However, the method only scheduled the next callback and never transmitted a ping frame (self.sendPing()was never called).Because of this:
self._last_pong_timeremainedNoneindefinitely, rendering the_loop_pong_checkconnection drop detector inactive.Solution
self.sendPing()inside_loop_ping()whenself.state == self.STATE_OPEN, wrapped in a safetry...exceptblock.self._last_pong_time = time.time()inonOpen()so timeout tracking starts immediately from handshake completion.onClose(), safely checkDelayedCall.active()before cancelling_next_pingand_next_pong_check.tests/unit/test_ticker.pyverifying that:_loop_pinginvokessendPingand updates_last_ping_time._loop_pong_checkcallsdropConnectionwhen pong timeout is exceeded._loop_pong_checkremains connected when heartbeats are healthy.onOpeninitializes_last_pong_timeand triggers_loop_ping.