Missing first event in catchup subscription

Hi,

My first post here, so hi!

I have been experimenting with Event Store for a project I am currently working on and have run into an issue with the catchup subscription code. I have followed this blog post: http://geteventstore.com/blog/20130707/catch-up-subscriptions-with-the-event-store/index.html and have the following code:

var settings = ConnectionSettings.Create();

settings.SetDefaultUserCredentials(new UserCredentials(“admin”, “changeit”));

var connection = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Loopback, 1113));

connection.Connect();

connection.SubscribeToStreamFrom("$et-ZoneExited", StreamPosition.Start, true, ZoneExitedEvents);

private static void ZoneExitedEvents(EventStoreCatchUpSubscription arg, ResolvedEvent resolvedEvent)

{

var receivedEvent = resolvedEvent.Event;

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

}

The problem is, I have 3 ZoneExited events in the “$et-ZoneExited” stream, but only 2 get written to the console. I have checked this with another event type and this shows the same behaviour. The first event also did not appear when I originally ran the console app without anything in the stream, then created the 3 events.

I am using the c# client, 2.0.2.0

Am i missing something obvious?

thanks!

Attaching screenshot of stream…

In the console i see:

0029 - ZoneExited

0030 - ZoneExited

Zone-Exited.png

pass null for your checkpoint to start

When you pass StreamPosition.Start into a subscription, you’re telling it that the last event you saw (and recorded the event number of) was 0, therefore it starts at 1.

There’s a new constant for this in v3 of the API named StreamCheckpoint.StreamStart (since you’re on 2.0.2, you can use null here instead - it’s the same thing). That means you have’t seen anything yet (your checkpoint has no value), so you’ll get events
from the start.

I’ll try to write some docs around this today.

James

Ahh ok thanks guys - it’s working now.

(I’d tried 0 and -1 but not null)

cheers

tom

Time travel to 2018 and I went down the same rabbit hole… While a small search and found this post and solved my problem.