WebSocket transport: Treat normal close frames as io.EOF (#7236)

Fixes https://github.com/XTLS/Xray-core/issues/7235#issuecomment-6353389899

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Soheil Fakourand风扇滑翔翼 authored and GitHub committed 2026-10-29 03:42:11 +00:00
1 parent 8a3c0cbf1d
commit ec124ff9e0
1 file changed
+6
@@ -46,6 +46,12 @@ func (c *connection) Read(b []byte) (int, error) {
for {
reader, err := c.getReader()
if err != nil {
// A close frame with a normal status (1000) or no status (1005) ends
// the byte stream the same way a FIN does, so report io.EOF instead
// of an error. Other close codes keep their error semantics.
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
return 0, io.EOF
}
return 0, err
}