Fix closing
This commit is contained in:
parent
b4d99b8d90
commit
a5dd8639fc
1 changed files with 2 additions and 6 deletions
|
@ -45,7 +45,6 @@ func (w *wsConn) Send(msg ToClient) (closed bool) {
|
||||||
case w.out <- msg:
|
case w.out <- msg:
|
||||||
default:
|
default:
|
||||||
log.Debug().Str("conn", w.RemoteAddr().String()).Msg("send channel not ready, closing")
|
log.Debug().Str("conn", w.RemoteAddr().String()).Msg("send channel not ready, closing")
|
||||||
close(w.out)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +90,6 @@ func (wm *wsManager) serveWS(w http.ResponseWriter, r *http.Request) {
|
||||||
func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) {
|
func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) {
|
||||||
defer func() {
|
defer func() {
|
||||||
reg.Unregister(c)
|
reg.Unregister(c)
|
||||||
conn.Close()
|
|
||||||
conn.CloseCh()
|
conn.CloseCh()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -115,7 +113,7 @@ func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("closing connection")
|
log.Debug().Str("conn", conn.RemoteAddr().String()).Msg("closing connection")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +135,7 @@ func (conn *wsConn) writePump() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("SetWriteDeadline")
|
log.Error().Err(err).Msg("SetWriteDeadline")
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok { // channel is closed
|
||||||
// nexus closed us
|
|
||||||
_ = conn.WriteMessage(websocket.CloseMessage, []byte{})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue