How are you supposed to handle dropped connections with eventstore?

I’m having a quite naive implementation right now where I try to deal with dropped connections. It looks something like this:

void Init(){

_connection = EventStoreConnectionWrapper.Connect();

Position? position = new Position();

_connection.SubscribeToAllFrom(position, false, HandleEvent, OnSubscriptionDropped);

}

private void OnSubscriptionDropped(EventStoreCatchUpSubscription obj)

{

var eventStoreAllCatchUpSub = obj as EventStoreAllCatchUpSubscription;

_connection = EventStoreConnectionWrapper.Connect();

_connection.SubscribeToAllFrom(eventStoreAllCatchUpSub.LastProcessedPosition, false, HandleEvent, OnSubscriptionDropped);

}

For some reason this doesn’t work, or it does work in the way that the OnSubscriptionDropped gets called, but the problem is that the client keeps on disconnecting all the time. It seems like it is running the initial catch up when doing the subscription, but after that it just tries to close the connection. It seems like the socket is gets closed according to the debug log, but I can’t figure out why.

Also, it is quite confusing when you can provide a function that you can use for when the subscription is dropped as well as specifying reconnect in the connection settings, which should be used?