Eventstore: OperationTimeout or MaxRetries are not triggered when server is unavailable

Created on 8 Oct 2017  路  4Comments  路  Source: EventStore/EventStore

As suggested in documentation I want to create a single IEventStoreConnection instance for my application and set MaxReconnections property to -1 to make it keep trying to reconnect if network connection is lost or for any other reason.

At the same time, if I don't have EventStore server available I would like operation I initiate to fail fast so that my application does not hang/wait for too long and consumer or my code get timely failure response. For example, if ES server is not reachable, the call to connection.AppendToStreamAsync or connection.SubscribeToStreamAsync will not resolve returning task unless connection is established and operation is attempted.

Is the any way to use single instance of the connection and fail operations by timeout or something if server is unreachable? Would it maybe be possible to introduce CancellationToken for such operations?

Most helpful comment

I came up with an approach of having two connections in my application. Quite similar to what was described in discussion mentioned by @Narvalex. I have one singleton connection with KeepReconnecting for subscriptions and one with fail fast configuration that I use for writes and to reconstitute aggregates. If second connection gets closed I recreate a connection transparently to the application.

All 4 comments

A sample for this issue is provided in this google groups question

And here there is an interesting conversation about this topic too

I came up with an approach of having two connections in my application. Quite similar to what was described in discussion mentioned by @Narvalex. I have one singleton connection with KeepReconnecting for subscriptions and one with fail fast configuration that I use for writes and to reconstitute aggregates. If second connection gets closed I recreate a connection transparently to the application.

Fixed with #1769. FailOnNoServerResponse() can be used on the connection.

Was this page helpful?
0 / 5 - 0 ratings