Fix rabbitmq reconnect problem (#3778)

This commit is contained in:
Aditya Manthramurthy 2017-02-21 01:35:21 +05:30 committed by Harshavardhana
parent 9eb8e375c5
commit 0a905e1a8a

View File

@ -18,6 +18,7 @@ package cmd
import (
"io/ioutil"
"net"
"github.com/Sirupsen/logrus"
"github.com/streadway/amqp"
@ -87,7 +88,14 @@ func (q amqpConn) Fire(entry *logrus.Entry) error {
ch, err := q.Connection.Channel()
if err != nil {
// Any other error other than connection closed, return.
if err != amqp.ErrClosed {
isClosedErr := false
if neterr, ok := err.(*net.OpError); ok &&
neterr.Err.Error() == "use of closed network connection" {
isClosedErr = true
} else if err == amqp.ErrClosed {
isClosedErr = true
}
if !isClosedErr {
return err
}
// Attempt to connect again.