From 2750ceb05594f4ea1ac8e1fe6728cf4a96eb5943 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Fri, 18 Oct 2024 18:51:09 +1030 Subject: [PATCH] x-pack/filebeat/input/streaming: log websocket bad handshake details (#41300) (cherry picked from commit 0c2f9e7988fd81f286ef53c3df62a6147293aced) --- CHANGELOG.next.asciidoc | 1 + x-pack/filebeat/input/streaming/websocket.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 8c6a49132d6..84d487df9b0 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -167,6 +167,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fixed failed job handling and removed false-positive error logs in the GCS input. {pull}41142[41142] - Bump github.com/elastic/go-sfdc dependency used by x-pack/filebeat/input/salesforce. {pull}41192[41192] - Improve modification time handling for entities and entity deletion logic in the Active Directory entityanalytics input. {pull}41179[41179] +- Log bad handshake details when websocket connection fails {pull}41300[41300] *Heartbeat* diff --git a/x-pack/filebeat/input/streaming/websocket.go b/x-pack/filebeat/input/streaming/websocket.go index ce0f086e558..1deaf8b07fa 100644 --- a/x-pack/filebeat/input/streaming/websocket.go +++ b/x-pack/filebeat/input/streaming/websocket.go @@ -228,7 +228,11 @@ func connectWebSocket(ctx context.Context, cfg config, url string, log *logp.Log if err == nil { return conn, response, nil } - log.Debugw("attempt %d: webSocket connection failed. retrying...\n", attempt) + if err == websocket.ErrBadHandshake { + log.Errorf("attempt %d: webSocket connection failed with bad handshake (status %d) retrying...\n", attempt, response.StatusCode) + continue + } + log.Debugf("attempt %d: webSocket connection failed. retrying...\n", attempt) waitTime := calculateWaitTime(retryConfig.WaitMin, retryConfig.WaitMax, attempt) time.Sleep(waitTime) }