Skip to content

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

Description

@Lx
  • 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions