Fix state handling issue in SignalClient #1004
Merged
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.
This PR solves a state handling issues in SignalClient on mobile clients (iOS in our case) when switching from mobile data to wifi.
This paragraph is an assumption from my side, feel free to correct me. When switching on Wifi, the operating system leaves the websocket connection open on mobile data to avoid reconnects. Due to high data volume, it kills the WebRTC connection though.
Now back to observations:
this.state
is set toRECONNECTING
connect
close
sets state toDISCONNECTING
and toDISCONNECTED
while cleaning up the websocketconnect
continues to setup a connectionreconnect
response right after the websocket connectsRECONNECTING
DISCONNECTED
, while the rest of the system repeatedly tries to initiate a connectionThe fix is to skip state update in
close
if we are closing the websocket as part of a reconnection (i.e. fromconnect
). We are already connecting, no need to set the state toDISCONNECTED
.