Repository navigation
Conversation
session_re_log_on built the payload with api_key=False and skip_auth=True, so the logon sent on a new connection carried only a timestamp. The server rejects it (-1102, apiKey missing), while the client marks the session as logged on and stops signing later requests. The re-logon is now signed like the first one, with apiKey, a fresh timestamp and a new signature. The stored request's params are copied, so nothing from one re-logon leaks into the next. Fixes binance#569 Co-Authored-By: Claude Opus 5.5 <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.
Fixes #569.
Problem
After a WebSocket API connection is renewed,
session_re_log_onre-sendssession.logonbuilt withapi_key=False, skip_auth=True. With those optionsws_api_payloadonly addstimestamp, so the logon goes out withoutapiKeyandsignature:The server answers
-1102 Mandatory parameter 'apiKey' was not sent, but the client setsis_session_log_on = Trueanyway and stops signing the requests that follow.Change
session_re_log_onnow builds the payload withapi_key=True, skip_auth=False, the same way the first logon is signed:apiKey, a freshtimestampand a newsignature.paramsare copied before signing, so the saved logon request is not modified and each reconnect signs from a clean copy.Tests
Added
TestSessionReLogOnincommon/tests/unit/test_websocket.py:apiKey,timestampandsignature;The first test fails on
masterand passes with the change.pytest testsincommon/passes (375 tests). The new test code is formatted withblack.Not included
is_session_log_onis still set as soon as the message is sent, without waiting for the server's reply. Setting it from the response would be more correct, but it changes the reconnect flow, so I left it out of this fix. Happy to follow up if you want it.🤖 Generated with Claude Code