mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
When `rpc.Client.Close()` is called, the TCP connection is torn down without sending a WebSocket Close frame. The server sees `websocket: close 1006 (abnormal closure): unexpected EOF` instead of a clean 1000 (normal closure). ### Root cause `websocketCodec.close()` delegates to `jsonCodec.close()` which calls `c.conn.Close()` — gorilla/websocket's `Conn.Close` explicitly "[closes the underlying network connection without sending or waiting for a close message](https://pkg.go.dev/github.com/gorilla/websocket#Conn.Close)" (per RFC 6455). ### Fix Send a WebSocket Close control frame (opcode 0x8, status 1000) before closing the underlying connection. Uses `WriteControl` with the same `encMu` mutex pattern already used by `pingLoop` for write serialization, and reuses the existing `wsPingWriteTimeout` (5s) constant. `WriteControl` errors are safe to ignore — the connection may already be broken by the time we attempt the close frame. Fixes #30482 |
||
|---|---|---|
| .. | ||
| testdata | ||
| client.go | ||
| client_example_test.go | ||
| client_opt.go | ||
| client_opt_test.go | ||
| client_test.go | ||
| context_headers.go | ||
| doc.go | ||
| endpoints.go | ||
| errors.go | ||
| handler.go | ||
| http.go | ||
| http_test.go | ||
| inproc.go | ||
| ipc.go | ||
| ipc_js.go | ||
| ipc_unix.go | ||
| ipc_wasip1.go | ||
| ipc_windows.go | ||
| json.go | ||
| metrics.go | ||
| server.go | ||
| server_test.go | ||
| service.go | ||
| stdio.go | ||
| subscription.go | ||
| subscription_test.go | ||
| testservice_test.go | ||
| tracing_test.go | ||
| types.go | ||
| types_test.go | ||
| websocket.go | ||
| websocket_test.go | ||