I’m trying to get use Embedded eventstore to do some integration testing. When running I get:
Exiting with exit code: 1.
Exit reason: The requested address is not valid in its context
``
The connection connects, however, but then I get “Authorization error” when trying to append an event, even though I explicitly set the user credentials. What am I doing wrong?
class Program
{
static void Main(string[] args)
{
var connection = CreateConnection().Result;
connection.AppendToStreamAsync(“test”, ExpectedVersion.Any, new UserCredentials(“admin”, “changeit”), new EventData(Guid.NewGuid(), “test”, true, Encoding.UTF8.GetBytes("{“foo” : ‘bar’}"), new byte[0])).Wait();
Console.ReadLine();
}
static async Task CreateConnection()
{
var noneIp = new IPEndPoint(IPAddress.None, 0);
var clusterVNode = EmbeddedVNodeBuilder
.AsSingleNode()
.RunInMemory()
.WithExternalTcpOn(noneIp)
.WithInternalTcpOn(noneIp)
.WithExternalHttpOn(noneIp)
.WithInternalHttpOn(noneIp)
.Build();
var nodeTcs = new TaskCompletionSource();
clusterVNode.NodeStatusChanged += (sender, args) =>
{
if (args.NewVNodeState == VNodeState.Master) nodeTcs.SetResult(true);
};
clusterVNode.Start();
await nodeTcs.Task;
var settings = ConnectionSettings.Create()
.UseConsoleLogger()
.EnableVerboseLogging()
.SetDefaultUserCredentials(new UserCredentials(“admin”, “changeit”))
.KeepReconnecting();
var connection = EmbeddedEventStoreConnection.Create(clusterVNode, settings);
var connectionTcs = new TaskCompletionSource();
connection.Connected += (sender, args) => connectionTcs.SetResult(connection);
await connection.ConnectAsync();
return await connectionTcs.Task;
}
}
``