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

This commit is contained in:
Greg 2018-10-26 00:37:18 -06:00 committed by Daniel Nelson
parent 133fabc672
commit 21208d2686
2 changed files with 2 additions and 1 deletions

View File

@ -249,6 +249,7 @@ func (q *AMQP) Write(metrics []telegraf.Metric) error {
if q.sentMessages >= q.MaxMessages && q.MaxMessages > 0 { if q.sentMessages >= q.MaxMessages && q.MaxMessages > 0 {
log.Printf("D! Output [amqp] sent MaxMessages; closing connection") log.Printf("D! Output [amqp] sent MaxMessages; closing connection")
q.client.Close()
q.client = nil q.client = nil
} }

View File

@ -55,7 +55,7 @@ func Connect(config *ClientConfig) (*client, error) {
log.Printf("D! Output [amqp] connected to %q", broker) log.Printf("D! Output [amqp] connected to %q", broker)
break 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 { if client.conn == nil {