Skip to content

Commit

Permalink
x-pack/filebeat/input/streaming: log websocket bad handshake details (#…
Browse files Browse the repository at this point in the history
…41300)

(cherry picked from commit 0c2f9e7)
  • Loading branch information
efd6 authored and mergify[bot] committed Oct 18, 2024
1 parent 36659a4 commit 3fc19a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix a bug in Salesforce input to only handle responses with 200 status code {pull}41015[41015]
- 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]
- Log bad handshake details when websocket connection fails {pull}41300[41300]

*Heartbeat*

Expand Down
6 changes: 5 additions & 1 deletion x-pack/filebeat/input/streaming/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 231 in x-pack/filebeat/input/streaming/websocket.go

View workflow job for this annotation

GitHub Actions / lint (windows)

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

Check failure on line 231 in x-pack/filebeat/input/streaming/websocket.go

View workflow job for this annotation

GitHub Actions / lint (windows)

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
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)
}
Expand Down

0 comments on commit 3fc19a5

Please sign in to comment.