Skip to content

Commit

Permalink
Prevent connection leak by closing unused connections in amqp output (i…
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton authored and Jean-Louis Dupond committed Apr 22, 2019
1 parent 9369c71 commit 144cb7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/outputs/amqp/amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (q *AMQP) Write(metrics []telegraf.Metric) error {

if q.sentMessages >= q.MaxMessages && q.MaxMessages > 0 {
log.Printf("D! Output [amqp] sent MaxMessages; closing connection")
q.client.Close()
q.client = nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/outputs/amqp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Connect(config *ClientConfig) (*client, error) {
log.Printf("D! Output [amqp] connected to %q", broker)
break
}
log.Printf("D! Output [amqp] error connecting to %q", broker)
log.Printf("D! Output [amqp] error connecting to %q - %s", broker, err.Error())
}

if client.conn == nil {
Expand Down

0 comments on commit 144cb7f

Please sign in to comment.