Skip to content
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

How to detect client timeouts/disconnects when implementing long polling #1724

Closed
frankosterfeld opened this issue Nov 23, 2023 · 1 comment

Comments

@frankosterfeld
Copy link

We're implementing a long polling scheme where the client sends a request, and the server blocks in the request handler until a server-side event occurs. The client has keep-alive enabled, and a 10s read timeout. To not block the worker thread forever/longer than needed, I'd like to detect the client disconnect, so that the request handler can periodically check for that, and abort waiting for the server-side event if the client connection is gone.

I see no API for that, is that missing, or by design?

(Alternatively, or in addition, I could implement a server-side timeout when waiting for the event, with the disadvantage that it might differ from the timeout used by the client, and that other disconnects wouldn't be detected)

@yhirose yhirose closed this as completed in c5c704c Dec 5, 2023
@yhirose
Copy link
Owner

yhirose commented Dec 5, 2023

@frankosterfeld I added DataSink::is_writable() with which you can check if the socket is still alive. You can see how it can be used in 'LongPollingTest.ClientCloseDetection' in test.cc. Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants