Newbie event store .NET client user

.NET Client version : eventstore.client.grpc 21.2.0
on .NET 5

Trying to listen to event store streams using a Hosted service.

The app is crashing , if the esdb connection is down.
What’s the retry mechanism available; so that the HostedService is not silently failing.

I assume, the GRPC client doesnot have any retry mechanism and its the client responsibility to provide one?

The client seems to be newing up HttpClient and is there some way to inject retry mechanism like Polly there?

The exception you get is

EventStore.Client.DiscoveryException: Failed to discover candidate in 10 attempts.
there are as you can see retries by default .

var settings = EventStoreClientSettings.Create(connection);
// settings.ConnectivitySettings.MaxDiscoverAttempts
// https://github.com/EventStore/EventStore-Client-Dotnet/blob/a853663cb06fcc70db12f0da20956f4afa63f3c7/src/EventStore.Client/GossipBasedEndpointDiscoverer.cs#L39

you can pass your own HttpMessageHandler : settings.CreateHttpMessageHandler
make sure you use the same kind of settings under the hood as

1 Like

When you subscribe, you can provide a function to handle errors, including disconnects.

Overall, making catch-up subscriptions reliable is not a super-easy task, and it never is for any kind of message delivery system like brokers, etc. I claim you’d always need some sort of middleware to handle things like retries, etc.

You can check how it’s done in Eventuous https://github.com/Eventuous/eventuous/tree/dev/src/EventStore/src/Eventuous.EventStore/Subscriptions

1 Like