coder / coder/websocket

Return net.ErrClosed from Read methods when connection is closed by us

Đang mở
#447 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
5.5k
Fork
372
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Whenever I close the connection I get this error and the server doesn't respond. Can you please help me here

My reader function;
-------------------
```
func WsReader(log *logger.LoggerEvent, requestCtx context.Context, wsConn *_websocket.Conn, requestId uuid.UUID, userId int32) {
for {
_, buff, err := wsConn.Read(requestCtx)
if err != nil {
if err != io.EOF {
log.Errorf(`Failed to read the data : ERROR : %s : CODE : %s`, err, _websocket.CloseStatus(err))
}
break
}

if len(buff) == 0 {
break
}

data := eventSchemaHandler.GetRootAsEventWrapper(buff, 0)
log.Infof("Event received : %s : USER_ID : %d", data.Event(), userId)
unionTable := new(flatbuffers.Table)
data.Payload(unionTable)
event.SerializeEvents(log, wsConn, unionTable, requestId, string(data.Event()), string(data.ClubId()))
}
}
```

My Connection Close function:
------------------------------
```
func CloseSocketConnection(wsConn *_websocket.Conn, clubId string, statusCode _websocket.StatusCode, msg string) {
wsConn.CloseRead(context.Background())
wsConn.Close(statusCode, msg)
}
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.