Skip to content

Commit 26dd4ac

Browse files
committed
Consider StatusGoingAway a io.EOF in NetConn
1 parent 20ccbc4 commit 26dd4ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

netconn.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import (
3333
// The Addr methods will return a mock net.Addr that returns "websocket" for Network
3434
// and "websocket/unknown-addr" for String.
3535
//
36-
// A received StatusNormalClosure close frame will be translated to EOF when reading.
36+
// A received StatusNormalClosure or StatusGoingAway close frame will be translated to
37+
// io.EOF when reading.
3738
func NetConn(c *Conn, msgType MessageType) net.Conn {
3839
nc := &netConn{
3940
c: c,
@@ -93,7 +94,7 @@ func (c *netConn) Read(p []byte) (int, error) {
9394
typ, r, err := c.c.Reader(c.readContext)
9495
if err != nil {
9596
var ce CloseError
96-
if xerrors.As(err, &ce) && (ce.Code == StatusNormalClosure) {
97+
if xerrors.As(err, &ce) && (ce.Code == StatusNormalClosure) || (ce.Code == StatusGoingAway) {
9798
c.eofed = true
9899
return 0, io.EOF
99100
}

0 commit comments

Comments
 (0)