fix(outputs/amqp): Close the last connection when writing error to avoid connection leaks (#10360)

This commit is contained in:
stitch cula 2022-01-07 06:04:46 +08:00 committed by GitHub
parent c353bace3a
commit 0b96d40b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -260,6 +260,9 @@ func (q *AMQP) Write(metrics []telegraf.Metric) error {
return err
}
} else {
if err := q.client.Close(); err != nil {
q.Log.Errorf("Closing connection failed: %v", err)
}
q.client = nil
return err
}