Skip to content

Allow for custom exponential backoff in websocket client #1395

@jakubno

Description

@jakubno

Custom exponential backoff

In asyncio client, there was introduced option to use an infinite asynchronous iterator to reconnect automatically on errors, more in docs.

There were set constants for exponential backoff: client.py. But it's too slow for my use case. I would like to shorten it and I would prefer some cleaner way than this:

auto_reconnect = websockets.connect(...)
auto_reconnect.BACKOFF_INITIAL = 1
async for websocket in auto_reconnect:
    try:
        ...
    except websockets.ConnectionClosed:
        continue

Ideally it should be a parameter of the connect function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions