Skip to content

Commit

Permalink
feat: update timer relative to last update time
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Aug 22, 2024
1 parent 5bd05cb commit a0d0f42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion node/pkg/wss/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func (ws *WebsocketHelper) Run(ctx context.Context, router func(context.Context,
log.Info().Str("endpoint", ws.Endpoint).Msg("reconnect interval exceeded during read, closing websocket")
break innerLoop
case <-inactivityTimer.C:
inactivityTimer.Reset(ws.InactivityTimeout)
if time.Since(ws.lastMessageTime) > ws.InactivityTimeout {
log.Info().Str("endpoint", ws.Endpoint).Msg("inactivity timeout exceeded, closing websocket")
break innerLoop
}
inactivityTimer.Reset(ws.InactivityTimeout - time.Since(ws.lastMessageTime))
default:
data, err := readFunc(ctx, ws.Conn)
if err != nil {
Expand Down

0 comments on commit a0d0f42

Please sign in to comment.