Compare commits

...

2 commits

Author SHA1 Message Date
46db72b2cc
[overlays] Reduce socket abnormal closure to warning
resolves TWITCH-BOT-A

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-03-23 12:16:10 +01:00
c3085ea7f9
[eventsub] Suppress error on abnormal closure and reconnect
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-03-23 12:03:39 +01:00
2 changed files with 15 additions and 2 deletions

View file

@ -405,12 +405,21 @@ func handleSocketSubscription(w http.ResponseWriter, r *http.Request) {
case err == nil:
// We use nil-error to close the connection
case errors.As(err, &cErr) && websocket.IsCloseError(cErr, websocket.CloseNormalClosure, websocket.CloseGoingAway):
case errors.As(err, &cErr):
switch cErr.Code {
case websocket.CloseAbnormalClosure:
logger.WithError(err).Warn("overlay websocket was closed abnormally")
case websocket.CloseNormalClosure, websocket.CloseGoingAway:
// We don't need to log when the remote closes the websocket gracefully
default:
logger.WithError(err).Error("message processing caused error")
}
default:
logger.WithError(err).Error("message processing caused error")
}
return // All errors need to quit this function
case msg := <-sendMsgC:

View file

@ -385,6 +385,10 @@ func (e *EventSubSocketClient) handleSocketError(err error, msgC chan eventSubSo
e.logger.Debug("websocket was closed normally")
return nil
case websocket.CloseAbnormalClosure:
e.logger.Warn("websocket reported abnormal closure")
return errors.Wrap(e.connect(e.socketDest, msgC, errC, "network-error"), "re-connecting after abnormal closure")
default:
// Some non-twitch close code we did not expect
e.logger.WithError(closeErr).Error("websocket reported unexpected error code")