mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
[UPDATED] Reduce report of failed connection attempts
This applies to routes, gateways and leaf node connections. The failed attempts will be printed at the first, after the first minute and then every hour. The connect/error statements now include the attempt number. Note that in debug mode, all attempts are traced, so you may get double trace (one for debug, one for info/error). Resolves #969 Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -165,6 +165,9 @@ func (s *Server) connectToRemoteLeafNode(remote *leafNodeCfg) {
|
||||
|
||||
var conn net.Conn
|
||||
|
||||
const connErrFmt = "Error trying to connect as leaf node to remote server (attempt %v): %v"
|
||||
|
||||
attempts := 0
|
||||
for s.isRunning() && s.remoteLeafNodeStillValid(remote) {
|
||||
rURL := remote.pickNextURL()
|
||||
url, err := s.getRandomIP(resolver, rURL.Host)
|
||||
@@ -177,7 +180,11 @@ func (s *Server) connectToRemoteLeafNode(remote *leafNodeCfg) {
|
||||
conn, err = net.DialTimeout("tcp", url, dialTimeout)
|
||||
}
|
||||
if err != nil {
|
||||
s.Errorf("Error trying to connect as leaf node to remote server: %v", err)
|
||||
attempts++
|
||||
s.Debugf(connErrFmt, attempts, err)
|
||||
if shouldReportConnectErr(attempts) {
|
||||
s.Errorf(connErrFmt, attempts, err)
|
||||
}
|
||||
select {
|
||||
case <-s.quitCh:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user