Getting Started Sample Exception

Hi All

Just trying to get started using the .Net Api Quick Start Sample and code below. Seems I can connect ok, but get exception calling AppendToStreamAsync. Unfortunately the Exception just states that one

or more exceptions occurred and connection was closed. Any help would really be appreciated.

Thank you

var connection = EventStoreConnection.Create(“ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500”);

// Don’t forget to tell the connection to connect!
connection.ConnectAsync().Wait();

var myEvent = new EventData(
Guid.NewGuid(),
“testEvent”,
false,
Encoding.UTF8.GetBytes(“some data”),
Encoding.UTF8.GetBytes(“some metadata”)
);

// Throws Exception
connection.AppendToStreamAsync(
“test-stream”,
ExpectedVersion.Any,
myEvent
).Wait();

var streamEvents =
    connection.ReadStreamEventsForwardAsync("test-stream", 0, 1, false).Result;

var returnedEvent = streamEvents.Events[0].Event;

Console.WriteLine("Read event with data: {0}, metadata: {1}",
   Encoding.UTF8.GetString(returnedEvent.Data),
   Encoding.UTF8.GetString(returnedEvent.Metadata));

``

Did you change the default ports for the Event Store instance? 1113 is the default tcp port.

Catch the exception from the AppendToStreamAsync and let us know what the InnerException is… I suspect it’s ‘Connection ‘ES-{Guid}’ was closed’ and this means that the connection to Event Store was not successful.

I just tested against Event Store Server 3.3.0 (Latest available from https://geteventstore.com/downloads/) and Client 3.3.1 (The latest available from NuGet) and it works.

Thank for your reply.

Ok seems the problem was specifying hostname as localhost instead of 127.0.0.1. Although I think localhost should have worked.

Anyway thanks for your help.