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

Client connections always time out after 5 minutes by default, and this is not documented #161

Open
Lx opened this issue Jul 7, 2022 · 1 comment

Comments

@Lx
Copy link

Lx commented Jul 7, 2022

  • Python version: 3.10.4
  • Operating System: macOS 12.4 (21F79)
  • aiohttp version: 3.8.1

This is related to #2 but is not a duplicate as it concerns documentation, and the previous issue was closed before the circumstances of the timeout were fully understood.

Description

  1. Regardless of keep-alive activity, the default usage of sse_client.EventSource as given in the README times out after 5 minutes:

    async with sse_client.EventSource(
        'https://stream.wikimedia.org/v2/stream/recentchange'
    ) as event_source:
        ...
  2. There is no documentation in the README to state that this will occur.

Resolution

Ideally one of two things would resolve this issue:

  1. Remove the default timeout, which is what aiosseclient does.

  2. If there is sufficient* justification to keep the timeout, then document the justification and the workaround in the README:

    Timeouts

    Note that aiohttp requests have a default timeout of 5 minutes, inclusive of all traffic—that is, all aiohttp-sse-client requests will unconditionally time out after 5 minutes regardless of activity. This default has been retained in aiohttp-sse-client because ...

    To prevent this behaviour, disable the timeout by passing a timeout argument to the underlying request call:

    async with sse_client.EventSource(
        'https://stream.wikimedia.org/v2/stream/recentchange',
        timeout=None,
    ) as event_source:
        ...
    • It's important to note that this default timeout fires unconditionally, even if keep-alive activity occurs, and exists in aiohttp because it is a sensible default for normal traffic (not long-running SSE traffic).
@Lx
Copy link
Author

Lx commented Jul 7, 2022

A third option, which would probably be the best of both worlds, is to set a default aiohttp.ClientTimeout instance that has no total timeout but still provides a reasonable default timeout value for sock_connect only.

This option satisfies the maintainer's desire to keep a default timeout, but makes the timeout sensible for SSE traffic.

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

1 participant