Merge pull request #1742 from c9s/c9s/fix-ws-close-err

FIX: types/stream: change errorf to warnf
This commit is contained in:
c9s 2024-09-12 17:46:24 +08:00 committed by GitHub
commit 0d6b7b29d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -249,7 +249,7 @@ func (s *StandardStream) Read(ctx context.Context, conn *websocket.Conn, cancel
default:
if err := conn.SetReadDeadline(time.Now().Add(readTimeout)); err != nil {
log.WithError(err).Errorf("set read deadline error: %s", err.Error())
log.WithError(err).Errorf("unable to set read deadline: %v", err)
}
mt, message, err := conn.ReadMessage()
@ -300,7 +300,7 @@ func (s *StandardStream) Read(ctx context.Context, conn *websocket.Conn, cancel
var e interface{}
e, err = s.parser(message)
if err != nil {
log.WithError(err).Errorf("websocket event parse error, message: %s", message)
log.WithError(err).Errorf("unable to parse the websocket message. err: %v, message: %s", err, message)
// emit raw message even if occurs error, because we want anything can be detected
s.EmitRawMessage(message)
continue
@ -352,7 +352,7 @@ func (s *StandardStream) ping(
}
if err := conn.WriteControl(websocket.PingMessage, nil, time.Now().Add(writeTimeout)); err != nil {
log.WithError(err).Error("ping error", err)
log.WithError(err).Warnf("unable to write ws control message, ping error: %v", err)
s.Reconnect()
return
}
@ -439,7 +439,7 @@ func (s *StandardStream) reconnector(ctx context.Context) {
log.Warnf("re-connecting...")
if err := s.DialAndConnect(ctx); err != nil {
log.WithError(err).Errorf("re-connect error, try to reconnect later")
log.WithError(err).Warnf("re-connect error: %v, will reconnect again later...", err)
// re-emit the re-connect signal if error
s.Reconnect()