-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
panic: repeated read on failed websocket connection #476
Comments
t, msg, err := ws.ReadMessage() // this line caused the panic
You need to handle the error and break out of the loop.
…On Wed, Jan 30, 2019 at 10:14 PM leeqi ***@***.***> wrote:
type WsConn struct {
*websocket.Conn
proxy string
host string
path string
closed bool
....................
}
func (ws *WsConn) StartToReceiveMessage() {
go func() {
for {
t, msg, err := ws.ReadMessage() // this line caused the panic
if ws.closed {
glog.V(7).Infof("websocket closed.....")
return
}
ws.fireMessage(err, t, msg)
}
}()
}
I create the connection to the server and subsribe some api.
run after few seconds.....
panic: repeated read on failed websocket connection
goroutine 69 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0xc00017a160,
0xc000092008, 0xc0003f1fa8, 0x2, 0x2, 0xb)
D:/GoWork/src/github.com/gorilla/websocket/conn.go:968 +0x35d
github.com/gorilla/websocket.(*Conn).ReadMessage(0xc00017a160, 0x2, 0x2,
0xb, 0x0, 0x0, 0xc0002402c0)
D:/GoWork/src/github.com/gorilla/websocket/conn.go:1029 +0x36
Process finished with exit code 2
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#476>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABIcFt0_0Mz98HT-n9jROqhuBLFzlS6ks5vIomzgaJpZM4abprI>
.
|
Break out of the loop on error. |
I still encounter this problem, Is the bug fixed? |
@TangMonk - without your code it's not clear if you have the same problem, but this is likely a bug in your application code, not in websocket. |
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
type WsConn struct {
*websocket.Conn
proxy string
host string
path string
closed bool
....................
}
func (ws *WsConn) StartToReceiveMessage() {
go func() {
for {
t, msg, err := ws.ReadMessage() // this line caused the panic
if ws.closed {
glog.V(7).Infof("websocket closed.....")
return
}
ws.fireMessage(err, t, msg)
}
}()
}
I create the connection to the server and subsribe some api.
run after few seconds.....
panic: repeated read on failed websocket connection
goroutine 69 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0xc00017a160, 0xc000092008, 0xc0003f1fa8, 0x2, 0x2, 0xb)
D:/GoWork/src/github.com/gorilla/websocket/conn.go:968 +0x35d
github.com/gorilla/websocket.(*Conn).ReadMessage(0xc00017a160, 0x2, 0x2, 0xb, 0x0, 0x0, 0xc0002402c0)
D:/GoWork/src/github.com/gorilla/websocket/conn.go:1029 +0x36
Process finished with exit code 2
The text was updated successfully, but these errors were encountered: