event API seems not blocking?


#1

After a series of long polling there is no new event. I expect another long polling will get blocked but it seems that it always return the last event? How to get it blocked if there is no new event? Thanks!


(Jakob Borg) #2

Ask for the next event ID.

https://docs.syncthing.net/rest/events-get.html


#3

Thanks a lot. Now it does block. One more question: when I read the Event API document, I found that in general all events have a “id” and a “globalID”. However when I get into the details such as FolderCompletion, it does NOT show a “globalID” item. Is this an error of the document, or it is actually no "“globalID” in the JSON? Thanks.


(Simon) #4

Those examples may be outdated - every event has both id and globalID. For FolderCompletion it is definitely the case that it’s outdated, as the timestamp is from 2015, while the global id was introduced later.


#5

Thanks for the clarification. Is there a way to avoid missing event when using long polling? I noticed that there are several globalIDs missed in the middle。 Thanks,


(Jakob Borg) #6

Don’t look at the global ID to determine if you missed events - look at the id attribute which is specific to your subscription. There might be event types that are not part of your subscription and hence increase global ID but do not show up in your event stream.


#7

I have subscribed all event types (by calling with ?since=lastID); the returned id is continuous and I assume there is no missing event. For some reason I never received a LocalChangeDetected event when I change local files. I DID get ItemStarted/ItemFinished events when remote files got changed. How to get/determine the local file change events? FolderSummary/FolderCompletion only provide overall information. But I would like to show individual file changes (on local and remote sides)


(Simon) #8

Yeah, that’s an apparently undocumented change (that even happened quite a while ago): /rest/events returns all events except changes (LocalChangeDetected and RemoteChangeDetected), while /rest/events/disk returns exactly these events. If you’d want to open an issue (or even document it yourself :wink: ) at https://github.com/syncthing/docs, that would be much appreciated.


#9

Thanks for the information. From where I can find additional events information? Only from source code? if so which part should I read? I will go through it and see if I can collect them and put them together.


(Simon) #10

There isn’t much code: Rest endpoints are defined here: https://github.com/syncthing/syncthing/blob/master/cmd/syncthing/gui.go#L271
The relevant masks are here: https://github.com/syncthing/syncthing/blob/master/cmd/syncthing/gui.go#L56

I’d just add the /rest/events/disk similar to the existing /rest/events here: https://docs.syncthing.net/dev/rest.html#event-endpoints and extend the description of the events api accordingly: https://docs.syncthing.net/dev/events.html#description