Fix rabbitmq reconnect problem (#3778)

master
Aditya Manthramurthy 8 years ago committed by Harshavardhana
parent 9eb8e375c5
commit 0a905e1a8a
  1. 10
      cmd/notify-amqp.go

@ -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.

Loading…
Cancel
Save