Skip to content

Commit

Permalink
fix: correct logic for reconnect loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 22, 2024
1 parent 721f874 commit d643cb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,17 @@ func (c *wsConn) tryReconnect(ctx context.Context) bool {
var conn *websocket.Conn
for conn == nil {
time.Sleep(c.reconnectBackoff.next(attempts))
if ctx.Err() != nil {
return
}
var err error
if conn, err = c.connFactory(); err != nil {
log.Debugw("websocket connection retry failed", "error", err)
}
select {
case <-ctx.Done():
break
return
default:
continue
}
attempts++
}
Expand Down

0 comments on commit d643cb6

Please sign in to comment.