rpc: send clean close frame on websocket disconnect#20788
rpc: send clean close frame on websocket disconnect#20788Sahil-4555 wants to merge 6 commits intoerigontech:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make RPC server–initiated WebSocket disconnects appear as a clean, normal WebSocket closure (1000) to peers, instead of an abnormal closure (1006), by explicitly sending a Close control frame before tearing down the connection.
Changes:
- Send a WebSocket Close frame (
StatusNormalClosure) inwebsocketCodec.Close()prior to shutting down the JSON codec and ping loop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d6fb707 to
a054ecf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c4925f2 to
d0e6dcb
Compare
|
@Sahil-4555 fix lint plz |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e2cb486 to
e686d6d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Currently, when a WebSocket connection is closed by the RPC server, the underlying TCP connection gets torn down immediately without sending a final WebSocket Close frame. Because of this abrupt teardown, clients connected to the node experience an abnormal closure (error code 1006) instead of a clean, normal disconnect (error code 1000).
This PR fixes that behavior by explicitly sending a clean 1000 normal closure frame right before terminating the connection. It uses the
Close()method from thecoder/websocketlibrary to safely transmit this control frame.