Skip to content

Commit

Permalink
Merge pull request #1742 from c9s/c9s/fix-ws-close-err
Browse files Browse the repository at this point in the history
FIX: types/stream: change errorf to warnf
  • Loading branch information
c9s authored Sep 12, 2024
2 parents 2784ef4 + ea8f3a5 commit 0d6b7b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/types/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0d6b7b2

Please sign in to comment.