Wednesday, February 18, 2015

How to solve problem "Read access denied for stream" while reading events from event store?

Get this error on following line:
var event = connection.ReadStreamEventsForwardAsync(streamid, 0, 1, false).Result;

Need to add credential for reading
var event = connection.ReadStreamEventsForwardAsync(streamid, 0, 1, false,  new UserCredentials("admin", "changeit")).Result;

How to solve problem "System.AggregateException: One or more errors occured ---> EventStore.ClientAPI.Exceptions.RetriesLimitReachedException" when try to connect to write event to Event Store?

This error happened  after downloaded Event Store 3.0.1 and tried following code for the testing

            string serverIpaddress = "127.0.0.1";
            var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Parse(serverIpaddress), 2113));
            connection.ConnectAsync().Wait();
            var myEvent = new EventData(Guid.NewGuid(), "testEvent", false,
                                        Encoding.UTF8.GetBytes("some data1"),
                                        Encoding.UTF8.GetBytes("some metadata"));
            connection.AppendToStreamAsync("test-stream",
                               ExpectedVersion.Any, myEvent).Wait();

On line of AppendToStreamAsync, exception throws:
 "System.AggregateException: One or more errors occured ---> EventStore.ClientAPI.Exceptions.RetriesLimitReachedException"

Cause: .NET API of Event Store goes by TCP port, which default value is 1113, http port number is 2113 by default.

Just change to            
          var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Parse(serverIpaddress), 1113));

Reference
https://groups.google.com/forum/#!topic/event-store/5uWEqybibw8