Useful debug stuff
This commit is contained in:
parent
44b9fde32a
commit
7f2709ea0b
1 changed files with 6 additions and 0 deletions
|
@ -43,6 +43,7 @@ func (w *wsConn) Send(msg *pb.Message) (closed bool) {
|
||||||
select {
|
select {
|
||||||
case w.out <- msg:
|
case w.out <- msg:
|
||||||
default:
|
default:
|
||||||
|
log.Debug().Str("conn", w.RemoteAddr().String()).Msg("send channel not ready, closing")
|
||||||
close(w.out)
|
close(w.out)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -101,9 +102,11 @@ func (conn *wsConn) readPump(reg Registry, c Client) {
|
||||||
_, message, err := conn.ReadMessage()
|
_, message, err := conn.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||||
|
log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("unexpected close")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("closing connection")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,17 +133,20 @@ func (conn *wsConn) writePump() {
|
||||||
|
|
||||||
w, err := conn.NextWriter(websocket.BinaryMessage)
|
w, err := conn.NextWriter(websocket.BinaryMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("nextWriter error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.writeMessage(w, msg)
|
conn.writeMessage(w, msg)
|
||||||
|
|
||||||
if err := w.Close(); err != nil {
|
if err := w.Close(); err != nil {
|
||||||
|
log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("close error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-pingTicker.C:
|
case <-pingTicker.C:
|
||||||
conn.SetWriteDeadline(time.Now().Add(writeWait))
|
conn.SetWriteDeadline(time.Now().Add(writeWait))
|
||||||
if err := conn.WriteMessage(websocket.PingMessage, nil); err != nil {
|
if err := conn.WriteMessage(websocket.PingMessage, nil); err != nil {
|
||||||
|
log.Debug().Err(err).Msg("x ping failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue