Authentication Issue

Hi

I am using an Embedded Event Store for testing. I ran into an authentication issue that I am hopping you can help me resolve:

I start Event Store node like so

ClusterVNode node = EmbeddedVNodeBuilder.AsSingleNode()

.OnDefaultEndpoints()

.RunInMemory()

.RunProjections(ProjectionsMode.All);

node.Start();

then I create connection to it on status change:

var settings = ConnectionSettings.Create();

settings.SetDefaultUserCredentials(new UserCredentials(“admin”, “changeit”));

settings.FailOnNoServerResponse().EnableVerboseLogging().UseConsoleLogger();

var connection = EmbeddedEventStoreConnection.Create(node, settings, “TestConnection”);

await connection.ConnectAsync();

Then I right an event to it:

IList events = new List();

events.Add(new EventData(Guid.NewGuid(), “test”, true, Encoding.UTF8.GetBytes("{“foo” : ‘bar’}"), new byte[0]));

await connection.AppendToStreamAsync(Stream, ExpectedVersion.Any, events, userCredentials);

This fails with authentication error:

If I connect to Event Store running from command line following function works fine. Is Embedded node using same default Authentication userid and password

and if not how can I tell Embedded node which UserId and Password to authenticate with?

await connection.AppendToStreamAsync(Stream, ExpectedVersion.Any, events, userCredentials);

Thanks,

Vitaly.

You need to handle NodeStatusChanged on ClusterVNode. IIRC if the new state is Master or Slave then GES is almost ready to accept writes. Occasionally the authentication provider will not be ready by then, in which case you should get a NoResultException. I’ve been trying to figure out a nice way of handling this rare case but no luck :stuck_out_tongue: