Return net.ErrClosed from Read methods when connection is closed by us
- 主要语言
- Go
- 星标
- 5.5k
- 派生
- 372
- PR 合并指标
- 30 天内没有已合并 PR
描述
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)
}
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先跟踪报告中显示的 Read、CloseRead 和 Close 调用,然后检查本地关闭的连接是如何报告给调用方的。根据 issue 标题确认所需行为:当此库关闭连接时,Read 方法应返回 net.ErrClosed,并覆盖所演示的读取和关闭顺序。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go
- 领域
- networking
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100