Skip to content

Commit

Permalink
signalmeow/web: add small sleep for all reconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 17, 2024
1 parent b01a912 commit 4b63486
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/signalmeow/web/signalwebsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (s *SignalWebsocket) connectLoop(
backoff := initialBackoff
retrying := false
errorCount := 0
isFirstConnect := true
for {
if retrying {
if backoff > maxBackoff {
Expand All @@ -194,11 +195,14 @@ func (s *SignalWebsocket) connectLoop(
log.Warn().Dur("backoff", backoff).Msg("Failed to connect, waiting to retry...")
time.Sleep(backoff)
backoff += backoffIncrement
} else if !isFirstConnect {
time.Sleep(1 * time.Second)
}
if ctx.Err() != nil {
log.Info().Msg("ctx done, stopping connection loop")
return
}
isFirstConnect = false

ws, resp, err := OpenWebsocket(ctx, s.path)
if resp != nil {
Expand Down

0 comments on commit 4b63486

Please sign in to comment.