mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-14 10:10:42 -07:00
When A connects to B and B connects to A (either based on static configuration - explicit routes, or because of auto-discovery - implicit routes), it is possible that each server initially registers the route from the opposite TCP connection. It will then result in each server dropping the connection. We were previously setting a retry flag in the first accepted route based on the name of servers, which means that regardless of duplicate detection, the server with the "smaller" server name would try to reconnect when the route connection was closed. For instance, suppose that server B connects to server A, when B disconnects, A would try to reconnect once to B. This became problematic in the case of configuration reload, because removing the route from B to A would still result in a route created from A to B. Also, when a route attempts a reconnect, a random delay is added to avoid repeated failure cycles that may occur in case where A connects to B and B to A.