-
Notifications
You must be signed in to change notification settings - Fork 17
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
asyncio.TimeoutError in default ClientSession #2
Comments
It seems you can just pass the from aiohttp_sse_client.client import EventSource
evt = EventSource("the url", timeout=-1) |
I think have a default timeout is better than none. In your protocol's design, you should have a keepalive design to keep the socket open. Just like the recommendation in MDN, you can send a comment line to keep the socket alive. If you still want to disable the timeout, @lanfon72 provides a good solution. Therefore, I am going to close this issue. |
@lanfon72 this doesn't work for me python 3.6.3 this works for me
|
To be clear, the default aiohttp timeout is being applied to the whole HTTP connection, not to individual reads from the connection, or to individual messages. So this suggestion:
Doesn't work. It doesn't matter what keepalives you send, with the default timeout, the connection will be closed after five minutes. Here is a simple but complete program, based on the example in the documentation, demonstrating this:
If you run this program, then after five minutes, it dies with a TimeoutError. This is not because people have stopped editing Wikipedia! I don't think it makes sense to have a timeout like that in an SSE client. The whole point of SSE is to consume a potentially never-ending stream of events. And so, i think that this library should disable the read timeout by default. |
I wish I had found this issue earlier instead of needlessly debugging my server and my internet connection!
Although this issue is closed, for posterity, I would like to cast one more vote to have a default timeout of
A 5-minute timeout (in total, disregarding all traffic and successful messages) simply doesn't make sense in the context of a long-running SSE stream. It makes sense for typical requests and responses, so it's a sensible I think the If the
|
@slavkoja, as the issue author, do you care to re-open it in case the maintainers are not monitoring comments on closed issues? |
@Lx be free to open new one, as i didn't close it, i cannot reopen it... |
session.close() need at the end |
Description
The default aiohttp's ClientSession (created by EventSource constructor) has ont timeout set, then default ClientSession's timeout happens after 5 min of operation:
I see, that i can post own ClientSession object to constructor, but IMO the timeout have to be disabled when no custom object is used. I solved this by adding ClientTimeout into aiohttp import and then prepare custom timeout with sock_read disabled:
The text was updated successfully, but these errors were encountered: