Skip to content

Commit

Permalink
fix: Reset timeout on successful Ping
Browse files Browse the repository at this point in the history
  • Loading branch information
philippseith committed Oct 7, 2023
1 parent 44901b4 commit 729f03b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ msgLoop:
case <-time.After(l.party.keepAliveInterval()):
// Send ping only when there was no write in the keepAliveInterval before
if time.Since(l.hubConn.LastWriteStamp()) > l.party.keepAliveInterval() {
_ = l.hubConn.Ping()
if err = l.hubConn.Ping(); err != nil {
break pingLoop

Check warning on line 111 in loop.go

View check run for this annotation

Codecov / codecov/patch

loop.go#L111

Added line #L111 was not covered by tests
}
}
// A successful ping or Write shows us that the connection is alive. Reset the timeout
timeoutTicker.Reset(l.party.timeout())
// Don't break the pingLoop when keepAlive is over, it exists for this case
case <-timeoutTicker.C:
err = fmt.Errorf("timeout interval elapsed (%v)", l.party.timeout())
Expand Down

0 comments on commit 729f03b

Please sign in to comment.