better and less logs for websocket abnormal closures.

This commit is contained in:
fiatjaf 2022-12-19 14:47:57 -03:00
parent 9684033223
commit 3b7800692f
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -66,8 +66,12 @@ func handleWebsocket(relay Relay) func(http.ResponseWriter, *http.Request) {
typ, message, err := conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(
err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
log.Warn().Err(err).Msg("unexpected close error")
err,
websocket.CloseGoingAway, // 1001
websocket.CloseNoStatusReceived, // 1005
websocket.CloseAbnormalClosure, // 1006
) {
log.Warn().Err(err).Str("ip", r.Header.Get("x-forwarded-for")).Msg("unexpected close error")
}
break
}