Search code examples
c#clientevent-sourcinglinqpadeventstoredb

Timed out waiting for client to be identified (ReadStreamEventsForwardAsync)


I am trying to connect to the GetEventStore version 3.2.2 using the 4.0.0 C# client API (EventStore.ClientAPI.dll). I have written this as a sample in LINQPad 5 so that I can figure out what is going wrong. The LINQPad query is setup for C# statements. Here is the user query that I've written so far.

var localHostAddressses = Dns.GetHostAddresses(Dns.GetHostName());
var localAddress = localHostAddressses.FirstOrDefault(ha => ha.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) ?? IPAddress.Loopback;
var endPoint = new IPEndPoint(localAddress, 1113);
var userCredentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit");

var settings = EventStore.ClientAPI.ConnectionSettings.Create();
settings.SetDefaultUserCredentials(userCredentials);
settings.UseConsoleLogger();
settings.WithConnectionTimeoutOf(TimeSpan.FromSeconds(2));
settings.LimitReconnectionsTo(1);
settings.SetOperationTimeoutTo(TimeSpan.FromSeconds(2));

using (var client = EventStore.ClientAPI.EventStoreConnection.Create(settings, endPoint))
{
    client.ConnectAsync().Wait();

    var streamName = "SpecialStreamName42";     
    var task = client.ReadStreamEventsForwardAsync(streamName, 0, 10, false);
    task.Wait();

    task.Result.Dump();
}

It produces the following output

[19,14:05:27.126,DEBUG] TcpPackageConnection: connected to [192.168.15.201:1113, L192.168.15.201:28239, {c4f69c94-254f-475c-883a-06e427fd4610}].
[08,14:05:29.176,INFO] ClientAPI TcpConnection closed [14:05:29.176: N192.168.15.201:1113, L192.168.15.201:28239, {c4f69c94-254f-475c-883a-06e427fd4610}]:
[08,14:05:29.176,INFO] Received bytes: 116, Sent bytes: 124
[08,14:05:29.176,INFO] Send calls: 3, callbacks: 3
[08,14:05:29.176,INFO] Receive calls: 4, callbacks: 3
[08,14:05:29.176,INFO] Close reason: [Success] Timed out waiting for client to be identified
[08,14:05:29.176,DEBUG] TcpPackageConnection: connection [192.168.15.201:1113, L192.168.15.201:28239, {c4f69c94-254f-475c-883a-06e427fd4610}] was closed cleanly.
[11,14:05:29.377,DEBUG] TcpPackageConnection: connected to [192.168.15.201:1113, L192.168.15.201:28240, {9373790b-6f43-4d3f-bf66-77325b529bd0}].
[19,14:05:31.427,INFO] ClientAPI TcpConnection closed [14:05:31.427: N192.168.15.201:1113, L192.168.15.201:28240, {9373790b-6f43-4d3f-bf66-77325b529bd0}]:
[19,14:05:31.427,INFO] Received bytes: 116, Sent bytes: 124
[19,14:05:31.427,INFO] Send calls: 3, callbacks: 3
[19,14:05:31.427,INFO] Receive calls: 4, callbacks: 3
[19,14:05:31.427,INFO] Close reason: [Success] Timed out waiting for client to be identified
[19,14:05:31.427,DEBUG] TcpPackageConnection: connection [192.168.15.201:1113, L192.168.15.201:28240, {9373790b-6f43-4d3f-bf66-77325b529bd0}] was closed cleanly.

My task.Wait(); on line 19 never completes and eventually the query ends with a AggregateException that one or more errors occurred. The inner exception reads "Connection 'ES-7a7e3dfb-db11-4a5c-872c-100ad7724ba2' was closed.". I'm following the examples that I have seen and I do not appear to be making any headway. Hopefully this is something stupid that I'm just not setting up that will allow my client to be notified. If you have any ideas, please let me know.


Solution

  • 4.0.0 client is compatible with ES 3.9.4 and above. The client 3.9.5 is compatible both ways.

    It is mentioned in their announcement, see Breaking Changes.