Skip to content

Commit

Permalink
Merge pull request #181 from philippseith/bugfix/#179_Ping_does_no_re…
Browse files Browse the repository at this point in the history
…set_Timeout

fix: Reset timeout on successful Ping
  • Loading branch information
philippseith authored Oct 9, 2023
2 parents e607000 + 729f03b commit ea39b9e
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
}
}
// 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 ea39b9e

Please sign in to comment.