Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always reconnect after connection closes
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: - The connection did not exit cleanly. This is needed to not make the socket reconnect after it is manually disconnected with `Socket#disconnect`. - The WebSocket exit code was not normal (something other than 1000). 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: phoenixframework@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
- Loading branch information