coder / coder/websocket

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

Aperta
#447 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
5.5k
Fork
372
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.