-
Notifications
You must be signed in to change notification settings - Fork 18k
WebSockets may occasionally fail to establish normal connections #70265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That would be an error of the the websocket library, please report to them. |
Problem location
The blocking positions occur on line 2 and line 49 respectively. It can be seen that the read - timeout limit of Solution
What I expect I hope someone can point out what the root cause of this problem is and come up with a more normal, reliable, and safe way to solve the problem of the inability to establish a normal WebSocket connection. |
Go version
go version go1.23.1 windows/amd64
Output of
go env
in your module/workspace:What did you do?
We are in the process of developing a software service related to WebSocket. We are using Go version 1.23.1. During the utilization of WebSocket for communication, we have encountered several obstacles.
Sometimes, the WebSocket connection fails to be established normally. This phenomenon consistently appears on some Windows 10 computers, while the majority of Windows 10 computers do not have this problem.
What did you see happen?
In order to reproduce this issue more conveniently, I have written the following most simplified code for establishing a WebSocket connection. In the code below, I use the Gin framework to monitor HTTP route requests. After receiving the HTTP requests from clients, I then use the github.com/gorilla/websocket library
(not just this library, I have also adopted other WebSocket - related libraries available online. Unfortunately, none of them can solve the problem I mentioned above)
to establish the WebSocket connection.I ran the above simple code on the environment where the problem occurred. After the service started to correctly listen on port 10020, I used the following code on the client side to establish a connection with the service.
Then I noticed that the
ws.readyState
remained at 0 all the time and never changed to 1, which indicates that both sides have been in the state of establishing a connection all along.I used the Wireshark tool to trace the entire process of establishing the connection. The whole process of the communication is shown in the figure below.

What did you expect to see?
Under normal circumstances, there should be a communication record of
Switching Protocols
next. Then the WebSocket connection can be successfully established. However, it is absent in the abnormal environment, which indicates that a blockage has occurred during the process of establishing communication.The text was updated successfully, but these errors were encountered: