-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
RPC Client doesn't gracefully close Websocket Connections #30482
Comments
Odd. In defer func() {
close(c.closing)
if reading {
conn.close(ErrClientQuit, nil)
c.drainRead()
}
close(c.didClose)
}() At some point, I'd have expected that to trickle down to the func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
if h == nil {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
return nil
}
}
c.handleClose = h
} |
So
This in turn calls Close on the Gorrillas WS conn as you say.
This function unfortunately just closes the TPC connection. The Close Handler only gets called if a CloseMessage is received. |
Hm, it seems this is a long-standing issue in gorilla/websocket: gorilla/websocket#448 |
Yeah not sure if they are going to include or if they expect devs to implement themselves. When I use gorilla/websocket I tend to do something like this to solve the issue:
Unfortunately this isn't possible with rpc Client as I don't have access to the WS conn itself. |
System information
Geth version:
1.14.8
OS & Version: OSX
Expected behaviour
When rpc.Client Close() is called, I would expect a message like this to be sent
Actual behaviour
The client closes the TCP conn without sending a WS Close message, leading to
websocket: close 1006 (abnormal closure): unexpected EOF
on the server side.Steps to reproduce the behaviour
Open a WS connection with the rpc.Client. Close the connection.
The text was updated successfully, but these errors were encountered: