Log reasons for disconnecting a websocket client.

This commit is contained in:
Josh Rickmar 2014-03-17 15:32:26 -05:00
parent a0ffa6bdab
commit 6be1d86df2

View file

@ -322,6 +322,7 @@ func WSSendRecv(ws *websocket.Conn) {
for { for {
var m []byte var m []byte
if err := websocket.Message.Receive(ws, &m); err != nil { if err := websocket.Message.Receive(ws, &m); err != nil {
log.Infof("Cannot receive client websocket message: %v", err)
close(received) close(received)
return return
} }
@ -351,11 +352,12 @@ func WSSendRecv(ws *websocket.Conn) {
case m := <-cc.send: case m := <-cc.send:
err := ws.SetWriteDeadline(time.Now().Add(deadline)) err := ws.SetWriteDeadline(time.Now().Add(deadline))
if err != nil { if err != nil {
log.Errorf("Cannot set write deadline: %v", err)
return return
} }
err = websocket.Message.Send(ws, m) err = websocket.Message.Send(ws, m)
if err != nil { if err != nil {
// Frontend disconnected. log.Infof("Cannot complete client websocket send: %v", err)
return return
} }
} }