mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-13 17:42:23 -04:00
[client] Fix error handling in Receive to properly re-establish stream and improve reconnection messaging
This commit is contained in:
@@ -108,7 +108,7 @@ func (c *GRPCClient) Send(event *proto.FlowEvent) error {
|
||||
func (c *GRPCClient) Receive(ctx context.Context, interval time.Duration, msgHandler func(msg *proto.FlowEventAck) error) error {
|
||||
backOff := defaultBackoff(ctx, interval)
|
||||
operation := func() error {
|
||||
if err := c.establishStreamAndReceive(ctx, msgHandler); err != nil {
|
||||
if err := c.establishStreamAndReceive(ctx, msgHandler); err == nil {
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return backoff.Permanent(err)
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func (c *GRPCClient) Receive(ctx context.Context, interval time.Duration, msgHan
|
||||
return err
|
||||
}
|
||||
log.Infof("connection recreated successfully")
|
||||
return nil
|
||||
return fmt.Errorf("connection recreated, re-establishing stream")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user