-
-
Notifications
You must be signed in to change notification settings - Fork 579
Description
I'm just trying some basic examples of websockets.
I'm using two different computers for client and server, so I have just adjusted the server host to be "" (all interfaces). First I tried a threading version:
from websockets.sync.server import serve
def hello(websocket):
name = websocket.recv()
print(f"< {name}")
greeting = f"Hello {name}!"
websocket.send(greeting)
print(f"> {greeting}")
with serve(hello, "", 8765) as server:
server.serve_forever()I can see the program listening at 8765 in the output of ss --tcp --listening --numeric:
LISTEN 0 128 0.0.0.0:8765 0.0.0.0:*
I can connect fine from the same server using the server ip/name or localhost:
websockets ws://myserver:8765
But if I try to connect from other computer (different network), with the same command, it can't connect and gives a timeout error:
Failed to connect to ws://myserver:8765: timed out during opening handshake.
I have tried to solve this, but I can't see where the problem is. Tried also with another server computer with the same results.
The asyncio version works flawlessly and I am able to connect to it from both localhost and remote computer, so I suspect some kind of bug here.
Can someone reproduce the problem? Am I missing something (probably really simple) here? thanks.
Server and client are Linux.
Python version is 3.13.11
There is no firewall running/installed in neither computer.
Websockets version is 15.0.1