From f809b1a9a5b4269d26fe6f6d7a488836989619d1 Mon Sep 17 00:00:00 2001 From: Daniel Kuiper <44123852+kuiperda@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:50:04 -0400 Subject: [PATCH] Recreate subscription if failing to read events --- pkg/stanza/operator/input/windows/input.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/stanza/operator/input/windows/input.go b/pkg/stanza/operator/input/windows/input.go index dc0061885ae4..27977e8e52f5 100644 --- a/pkg/stanza/operator/input/windows/input.go +++ b/pkg/stanza/operator/input/windows/input.go @@ -216,9 +216,13 @@ func (i *Input) read(ctx context.Context) int { events, err := i.subscription.Read(i.maxReads) if err != nil { i.Logger().Error("Failed to read events from subscription", zap.Error(err)) - i.subscription.Close() + closeErr := i.subscription.Close() + if closeErr != nil { + i.Logger().Error("Failed to close subscription", zap.Error(closeErr)) + return 0 + } + i.Logger().Info("Recreating subscription") i.subscription = NewRemoteSubscription(i.remote.Server) - i.Logger().Info("Reopening subscription") return 0 }