Reconnect immediately if connection fails on token expiry - #44
Merged
Conversation
steventux
force-pushed
the
fix/reconnect-immediately-on-token-expiry
branch
from
March 10, 2026 16:49
f6daaf5 to
04b6db0
Compare
steventux
force-pushed
the
fix/reconnect-immediately-on-token-expiry
branch
from
March 10, 2026 16:52
04b6db0 to
38fd146
Compare
If the connection closes for some other reason than token expiry, retry in 5 seconds.
Contributor
Author
|
@carlosmartinez I've added constants and a few more tests around other types of error. |
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
Token expiry is set to 3600 seconds, you do the math. This means that when the token expires we currently raise a
ConnectionClosedErrorwhich is caught in the main exception handler, this pauses for 5 seconds before reconnecting.We want to reconnect immediately so this PR amends the exception handling to detect
ConnectionClosedErrorwith a code of 1011 and "ExpiredToken" in the exception message and reconnect immediately.In testing this proved quicker than attempting to reconnect ahead of expiry time due to the way the
for message in websocket...loop executes.Jira link
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12425
Review notes
Review checklist