Always reconnect after connection closes #4924
Closed
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.
Phoenix creates a new WebSocket connection if the current one closes for
some reason. However, for a new connection to be created, it is required
that the following conditions hold:
socket reconnect after it is manually disconnected with
Socket#disconnect
.In some cases, the connection can close with the 1000 code and still
require reconnecting. For example, when turning the internet off for
around 1 minute, and turning it back on, then the connection sometimes
closes with code 1000.
You can test that behavior on my test site: http://34.219.19.64:5000/
Here is also a video of the issue reproduced by me: https://www.youtube.com/watch?v=j76SvA3kglQ
This commit removes the requirement for the condition that the
connection has to close with code 1000 to make reconnections more
reliable. I found that the condition was first added in November 2021
with no explanation on why it was needed in the first place:
470337d
If there is a good reason why this condition is set in place, do let me
know, but otherwise I would go ahead and remove it.
The new behavior can be tested on my second test site: http://34.219.19.64:5001/
Vide of the new behavior: https://www.youtube.com/watch?v=q06kPuTln9Q