Cannot get events to appear in subscriber

Hi,

I’ve been playing around with EventStore and have started to look at Subscriptions. I’ve created a very basic Console app which I believe I have setup to subscribe to all events and then write out some info to the console. The problem I have is that the EventAppeared method is never called when EventStore receives new events (via another app). Can somebody advice as to what I might be doing wrong

Here is the console app code:

internal class Program

{

private static readonly IEventStoreConnection connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113));

private static void Main(string[] args)

{

connection.SubscribeToAllAsync(

false,

EventAppeared,

subscriptionDropped: SubscriptionDropped,

userCredentials: new UserCredentials(“admin”, “changeit”));

connection.ConnectAsync();

Console.ReadLine();

}

private static void EventAppeared(EventStoreSubscription subscription, ResolvedEvent resolvedEvent)

{

var receivedEvent = resolvedEvent.OriginalEvent;

Console.WriteLine("{0:D4} - {1}", receivedEvent.EventNumber, receivedEvent.EventType);

}

private static void SubscriptionDropped(EventStoreSubscription subscription, SubscriptionDropReason reason, Exception exception)

{

Console.WriteLine(“Connection dropped”);

connection.SubscribeToAllAsync(false, EventAppeared, subscriptionDropped: SubscriptionDropped);

connection.ConnectAsync();

}

}

I am running the EventStore.ClusterNode.exe without an parameters. The version is 3.0.1.0. I believe it is currently running inmemory mode.

Thanks for the help.

Try connect first and wait on both it and the subscribe. Eg await/.wait and .result

Great, that works. Thanks Greg.