Prevent connection leak by closing unused connections in amqp output (#4924)

(cherry picked from commit 21208d2686)
This commit is contained in:
Greg
2018-10-25 23:39:33 -07:00
committed by Daniel Nelson
parent b18bab0b7c
commit 5592dc28e5
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -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
}
+1 -1
View File
@@ -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 {