Under what circumstances does the client reconnect?

My connections to a replica are moved to a master/leader right away. Thought it was a persistent subscriptions thing, but seems to be all subscriptions?

EventStoreConnection ‘xxxx’: going to reconnect to [Unspecified/10.1.0.63:1113]. Current endpoint: [Unspecified/10.1.0.67:1113, L10.1.0.53:54556].

63: Leader
67: Replica

I seem to have missed the PerformOnAnyNode setting, now it looks like persistent subscription is the only case for reconnect?

I’ll keep posting my findings here, hopefully it of use to someone, or future me:

Connecting to a follower or replica and starting a persistent subscription reconnects to leader.
Using Random node, and attempting a write on a replica does not reconnect to a capable node.

Restarting a replica seems to move all connections to the leader. A follower would be preferable, but can’t see any way to configure that?

Some points from me:

  • Node preference is not a hard rule, it’s best effort
  • You can’t append to the follower. You noticed the option right, but it will slow down things as your append requests will be still forwarded to the leader (obviously). So, the current behaviour forces you to retry the operation. During the retry, the client will re-gossip and connect to the leader for appends. Don’t use the client instance with node preference set to follower or replica for executing appends.
  • Persistent subscriptions only run on the leader as they checkpoint using events
  • I don’t there’s a preference “RoR or follower”, and I think we might need to introduce one. Opening an issue with such a suggestion would help :slight_smile:

if you need to connect to a RoR now:

Just have a scd connection string pointing to that specific node esdb://ror_address:2113

1 Like