-
-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Info stream #336
Info stream #336
Conversation
I've stumbled upon SSE just now, what do you think of it? https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events You made basically the same, except to support it I have to reinvent frontend support which SSE already has. Also, is there a way to ask for comments since time? In case of network error I can miss some of the comments, and then receive replies to them. |
sure, making it frontend-friendly should be easy. Probably we can also combine both events (info stream and last comments stream into a single "/events" endpoint) and allow partial subscription via query. regarding since parameter - not sure what you asking. Streams (events) are "since now", i.e. from the moment request received. Some regular calls have since parameter already, for example, |
I mean use case:
...or add "&url=post-url" to |
I have changed both streams, take a look if UI consumes it |
makes sense. Added an optional query param "since=unix-ts-msec" to both streaming calls |
Hm, it seems to barely working. It connects too long (about 10 seconds to 2 minutes, yikes), receives error after ~2 minutes, then again slowly reconnects. I've attached zipped html test file which connects to CURL seems to connect fine, but then again errors out with |
I don't get. What "connects too long" means? Technically it accepts connects right away and holds it open for some time. Maybe your client waits till connection closed?
What exactly slowly reconnect? Is it about frontend http client? I don't have anything related to reconnects.
curl will eventually fail on timeout due to inactivity. The default one is 15m on my side, but as far as I recall curl itself has timeout as well. I think it is |
I mean this is a time between EventSource call started and time it receives
Yes, EventSource api reconnects automatically after 3 seconds by default; can be changed (See
Maybe you right. But I noticed that I get this error response exactly after I post some comment. Also, I've found demo that seems to work fine with sse, and js there shows no magic, it's same: https://jsbin.com/vigehujara/edit?html,js,output
Curl doesn't timeout there. Unfortunately, I see no sources for its backend, so can't suggest anything concrete. |
From what I can see on my side the actual disconnect initiated by the client, I'm getting "stream closed by a remote client, context canceled". Probably this is addressed with setting keep-alive header. Another suspicious thing was a global server-level write timeout. With this pair of fixes, the example you gave me looks more stable. Pls take a look and let me know if you like or hate it ;) |
hmmm, It still behaves a bit odd: Trying to get last comments stream and you can see that it:
Is it intentional? Also, I noticed, that connection can be unstable when we dealing with nginx or somekind proxy. |
tried with
This is expected. Notifications are not trying to deliver a stream of updates but rather acts as notification of "change happened". The technical reason for skipped comment is here (request a single comment after sinceTime). It is possible to change the logic if needed and get up to N comments instead of 1 upd: let me know if you want to increase the limit and include up to N comments in the event's data. |
Yeah,
I don't think there is necessity, I just refetching last comments on event received, I don't even look at data it contains. |
regarding nginx - probably there are some magic parameters to make it play better with such streams. Maybe read timeout of some kind |
I dont see this code in master branch. |
we never implemented proper ui for this and decided to drop the code |
Pretty strange desicion. |
The code was designed with a very particular goal in mind - to provide a stream of updates for dynamic UI changes. The UI part never happened and so that API was removed.
Up to you. To me it sounds like a bad idea, but if you are willing to maintain your own fork and backport/merge changes from the master - sure, fine. Pls note - another reason we have dropped unused streaming API was due to some rare, but painful issues we had with concurrent tests. It didn't cause races but sometimes results of those tests were incorrect (unexpected). Maybe you can figure what was wrong with that code and provide PR with a fixed implementation. Another possible solution for your problem - call |
This one adds API to stream minimal updates for a given post. The goal is to provide UI with a way to subscribe to such update events and be able to refresh or notify the user (see #253)
The API is
/stream/info
and it allows smth like this:note: notification sent on the new/updated comment as well as on removed comments, so
count
may be decremented or incrementedThe stream can be terminated on timeout (no new comments for some time (currently 15 minutes) or by client-side closing the connection. The integration with frontend should start such a call on a comment page, listen to updates and reconnect as needed. It will be also nice to run on the active page only.