mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2025-01-08 20:41:30 +00:00
Compare commits
2 commits
031ad331e4
...
46db72b2cc
Author | SHA1 | Date | |
---|---|---|---|
46db72b2cc | |||
c3085ea7f9 |
2 changed files with 15 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue