diff --git a/operator/rpc_client.go b/operator/rpc_client.go index 2bef5337..0ac1d470 100644 --- a/operator/rpc_client.go +++ b/operator/rpc_client.go @@ -183,9 +183,21 @@ func (c *AggregatorRpcClient) tryResendFromDeque() { if err != nil { c.logger.Error("Couldn't resend message", "err", err) - if i == 0 { - c.logger.Error("Couldn't resend first message, most likely a connection error") - return + if err == rpc.ErrShutdown { + c.logger.Error("Couldn't resend message due to shutdown") + + if errorPos == 0 { + c.unsentMessages = c.unsentMessages[i:] + return + } + + for j := i; j < len(c.unsentMessages); j++ { + message := c.unsentMessages[j] + c.unsentMessages[errorPos] = message + errorPos++ + } + + break } c.unsentMessages[errorPos] = message