Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reset timeout on successful Ping #181

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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