Prevent connection leak by closing unused connections in amqp output (#4924)
This commit is contained in:
parent
133fabc672
commit
21208d2686
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue