I am trying to create persistent subscription for my tests, and can’t find a way to make it work without a sleep after node.Start(). If I wait for NodeStatusChanged than I am getting the “Authentication error” on CreatePersistentSubscriptionAsync.
class Program
{
static void Main(string[] args)
{
var node = EmbeddedVNodeBuilder
.AsSingleNode()
.OnDefaultEndpoints()
.RunInMemory()
.Build();
//var wait = new AutoResetEvent(false);
//node.NodeStatusChanged += (sender, arg) =>
//{
// if (arg.NewVNodeState == VNodeState.Master) wait.Set();
//};
node.Start();
Thread.Sleep(3000);
var settings = ConnectionSettings.Create()
.SetDefaultUserCredentials(new UserCredentials(“admin”, “changeit”));
var connection = EmbeddedEventStoreConnection.Create(node, settings);
connection.ConnectAsync().Wait();
connection.CreatePersistentSubscriptionAsync(“test”, “group”, PersistentSubscriptionSettings.Create(), null).Wait();
node.Stop();
}
}