Skip to content

Commit

Permalink
Log reconnect attempts (elastic#5715)
Browse files Browse the repository at this point in the history
  • Loading branch information
recrsn committed Jun 25, 2018
1 parent 35a7882 commit 0142a9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libbeat/publisher/pipeline/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,30 @@ func (w *netClientWorker) Close() error {

func (w *netClientWorker) run() {
for !w.closed.Load() {
reconnectAttempts := 0

// start initial connect loop from first batch, but return
// batch to pipeline for other outputs to catch up while we're trying to connect
for batch := range w.qu {
batch.Cancelled()

if w.closed.Load() {
logp.Info("Closed connection")
return
}

if reconnectAttempts > 0 {
logp.Info("Attempting to reconnect with %d reconnect attempt(s)", reconnectAttempts)
}

err := w.client.Connect()
if err != nil {
logp.Err("Failed to connect: %v", err)
reconnectAttempts++
continue
}

reconnectAttempts = 0
break
}

Expand Down

0 comments on commit 0142a9b

Please sign in to comment.