[ws-server] reset readTimeout when we receive something
This commit is contained in:
parent
8267920749
commit
9b5f21a650
|
@ -502,12 +502,16 @@ func (wsc *wsConnection) readRoutine() {
|
||||||
// We use `readTimeout` to handle read timeouts.
|
// We use `readTimeout` to handle read timeouts.
|
||||||
_, in, err := wsc.baseConn.ReadMessage()
|
_, in, err := wsc.baseConn.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
|
||||||
|
wsc.Logger.Info("Client closed the connection", "remote", wsc.remoteAddr)
|
||||||
|
} else {
|
||||||
wsc.Logger.Info("Failed to read from connection", "remote", wsc.remoteAddr, "err", err.Error())
|
wsc.Logger.Info("Failed to read from connection", "remote", wsc.remoteAddr, "err", err.Error())
|
||||||
// an error reading the connection,
|
}
|
||||||
// kill the connection
|
|
||||||
wsc.Stop()
|
wsc.Stop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
wsc.readTimeout.Reset(wsc.pongWait)
|
||||||
|
|
||||||
var request types.RPCRequest
|
var request types.RPCRequest
|
||||||
err = json.Unmarshal(in, &request)
|
err = json.Unmarshal(in, &request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue