Skip to content

[Feature request] More specific exception for connection refused #593

@gnachman

Description

@gnachman

I would like to retry making a connection when the remote is not listening on the port. This is a common use case for iTerm2's Python API, where scripts would like to launch the app and then connect to it once it has started.

Currently, when I do websockets.connect() and the remote isn't listening on the port it fails with OSError with arguments of Multiple exceptions: [Errno 61] Connect call failed ('::1', 1912, 0, 0), [Errno 61] Connect call failed ('127.0.0.1', 1912)

My current approach is to catch OSError and assume it is a connection failure that should be retried, but I'm sure there are other possible causes of OSError.

I see that websockets defines many exceptions: https://websockets.readthedocs.io/en/stable/api.html#websockets.exceptions.ConnectionClosed

My request is to add websockets.exceptions.ConnectionRefused(remotes), where remotes could hold the list of (ip,port) tuples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions