mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-28 10:31:29 +02:00
[client] Reset gRPC channel backoff when the network returns
Dials attempted by the gRPC channel while offline grow its internal exponential backoff, so after the network came back the reconnect loop sat in WaitForStateChange until that timer expired. Reset the channel backoff alongside the retry backoff so the management and signal reconnects dial immediately.
This commit is contained in:
@@ -233,6 +233,9 @@ func (c *GrpcClient) withMgmtStream(
|
||||
return nil //nolint:nilerr // a cancelled context means shutdown, not a retryable failure
|
||||
} else if waited {
|
||||
backOff.Reset()
|
||||
// dials attempted while offline grew the channel's internal backoff;
|
||||
// reset it too, or the reconnect waits out that timer first
|
||||
c.conn.ResetConnectBackoff()
|
||||
}
|
||||
|
||||
connState := c.conn.GetState()
|
||||
|
||||
@@ -197,6 +197,9 @@ func (c *GrpcClient) Receive(ctx context.Context, msgHandler func(msg *proto.Mes
|
||||
return nil
|
||||
} else if waited {
|
||||
backOff.Reset()
|
||||
// dials attempted while offline grew the channel's internal backoff;
|
||||
// reset it too, or the reconnect waits out that timer first
|
||||
c.signalConn.ResetConnectBackoff()
|
||||
}
|
||||
|
||||
c.notifyStreamDisconnected()
|
||||
|
||||
Reference in New Issue
Block a user