HTTP API - Subscribe to events

My current reading of the documentation is that if you want to want to subscribe to events, you have to use the .Net API; if you’re only using the HTTP API, you’d have to poll periodically to check for new events. Is this correct, or is there a trick I’m missing here?

Stuart

You follow the atom feed, once you hit the end of the atom feed your prev rel link will disappear, you then keep following the current link you have until a new prev link appears (you will get event data at the same time.

As for polling there is also another way which is long polling. This can be set by using the ES-LongPoll header (seconds to wait). When set the system will pretend like its being slow, internally subscribe, then deliver the event if it happens within the time period. I would suggest trying it using something like curl to better see how it works. Using LongPoll over all will give you much reduced latency over general polling.

Hope this helps,

Greg

Excellent, thanks - long polling sounds like it’ll do everything I want.

I should add for long polling you don’t really want to set the header until you get an empty feed. When you get the empty feed you are “caught up” at which point start setting the header.

I was struggling with Subscriptions over HTTP for a whole day,
and this was the missing piece I was needing for getting forward.

I’d suggest making this info more explicit in the docs.

e.g When using HTTP API the developer is responsible for the whole client subscription implementation,

such as (normal/long) polling, the ‘prev’ link in the atom feed, etc. (with some cURL examples as other stuff).

I’m already here so maybe you could sort out one thing for me-

When following the atom feed, why should i watch the ‘prev’ link (and not the ‘next’ link)?

Am I going forward or backwards on this atom feed?

I’ll be happy if someone could elaborate or reference me to the right place to read at.

Greg-

Thanks for this answer, and thanks for this awesome product.

Six months ago I started a journey, diving deep into DDD / ES / CQRS, Today I feel like you are my mentor (i’m sure others feel that way as well).

I started implementing Eventstore on my main greenfield project (used Kafka until now), and it feels amazing.

The only thing that’s a bit weird is the Documentation part, which I have a lot of feedback for, but that’s for another post,

the nice side of that is it forces me to jump into source code and actually -think- :wink:

Thanks for all you’ve given and giving to the software community.

Hope to say hi at upcoming DDD Europe :slight_smile:

Cheers

Thanks Gal, there are some basic docs here - https://eventstore.org/docs/getting-started/reading-subscribing-events/index.html but yes they need more detail that I’ll work on. I’ll add the disclaimer now.