Skip to content

Handshake error when connecting via ws+unix #300

@litteratum

Description

@litteratum

I have a WebSocket service that uses the gevent-websocket library. And ws4py connects to it via a Unix socket without issue.

Recently, I switched to flask-sock (uses simple-websocket under the hood) for the server.
And now handshake fails.

With trial and error (andd LLMs help), I discovered that a workaround is to set ws.port explicitly.
So, how I do it:

from ws4py.client.geventclient import WebSocketClient

_URL = "ws+unix:///tmp/sock.sock"

ws = WebSocketClient(_URL)

if ws.port is None:
    if ws.scheme == "wss":
        ws.port = 443
    else:
        ws.port = 80

ws.connect()

When the port is set, the handshake is now successful. Also, the port value is not important; even when set to "0", it works.

I see that the library always set the host (localhost in this case). Shouldn't the library also set the port?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions