EventStore/EventStore — pull request #209 by gregoryyoung (2014-09-06 18:03:29+00:00)
Title: Embeddedstatus

I am also seeing this issue when running ES in its in-memory mode (--mem-db). I will get this error if the EventStore process has not finished starting. My current hack for this is to Sleep for 5 seconds. :-(

It seems to me that either
there is a bug that ES does not internally wait from some sort of Initialized state before processing AppendToStream (or in my case SubscribeToAllAsync) method
there is a feature missing, not documented, or that I am unaware of, that allows me to gate my actions on the system being initialized. i.e. either an Event, WaitHandle or callback that can let me know that I can now access the system with a given user (in my test case just admin:changeit)
Has any one had any experience with this

Lee
(ES Newbie)

So I did some research on this.

The code in question:

https://github.com/EventStore/EventStore/blob/dev/src/EventStore.Core/Authentication/InternalAuthenticationProvider.cs#L46

if (completed.Result != ReadStreamResult.Success)
{
authenticationRequest.Unauthorized();
return;
}

Is whats causing it. Early in the life cycle the read gets rejected as the system is not yet ready. I added a NotReady status to the authentication which will give you a message to this regard over TCP and will give you a 503 + retry-after header for http (seems reasonable) PR will be up shortly.

For the state notifications for hosting event store yourself (eg embedded client) there is now an event on clustervnode that will let you know about state transitions its here:

https://github.com/EventStore/EventStore/commit/fd369f6c6718401a1b9fd1a0db1f35726a0d2813 this will allow you in your code to

myNode.NodeStatusChanged += handler to get any status updates from your self hosted vnode.