-
Notifications
You must be signed in to change notification settings - Fork 20k
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: WebSocket client treats pings as errors #19798
Comments
+1 for adhering to the websocket spec—this caused us a lot of confusion while debugging |
I am also working with websocket and face this error also. It would be great if this error be fixed soon. |
I will fix this by switching to github.com/gorilla/websocket. |
More information: this bug is present in Edit: The latest released version is now |
OK, it took me a bit to understand the details but I have it now. The issue here isn't that github.com/x/net/websocket doesn't handle ping (it does). We are seeing the reproducer behave this way because SetWriteDeadline interacts badly with the built-in ping frame handler. Whenever the RPC client wants to write something, it sets a write deadline. In the reproducer it only writes once to establish the subscription. When the ping frame arrives 12 seconds after the write, the write deadline that's set has already passed and writing the pong frame fails. The pong write error is returned from Read, causing the client to reconnect. |
@dphilipson v1.9.0 can't work for |
v1.9.0 can't work for SubscribeNewHead, need to update to latest (v1.9.1): ethereum/go-ethereum#19798 (comment)
Hello!
If the Go-Ethereum client connects to a server via WebSockets and uses
SubscribeNewHead
, then if that server sends a WebSocket ping message, the client treats this as an error and closes the connection. According to the WebSocket spec, either the client or server may send ping messages and the other endpoint should respond with a pong (see MDN or the WebSocket spec). Instead, if the server sends a ping then the connection is closed with an error.A repro is as follows, which creates a go-ethereum client that subscribes to a mock server. The mock server responds to the
eth_subscribe
request, then sends a WebSocket ping after 12 seconds.Running this produces the output:
The text was updated successfully, but these errors were encountered: