I'm currently testing a very basic socket example and even the basic test doesn't work. My Python code (server) is:
import socket
server = socket.socket(socket.AF_INET)
server.bind(("0.0.0.0", 5000))
server.listen(1)
conn, addr = server.accept()
My Javascript code (client) is:
var connection = new WebSocket("wss://<my-local-ip>:5000");
However, after starting my Python code and then running my Javascript code, the connection hangs on the WebSocket.CONNECTING
state for around half a minute before giving the error:
WebSocket connection to 'wss://192.168.0.119:5000/' failed: WebSocket opening handshake timed out
I also tried replacing <my-local-ip>
with my public IP (according to ipinfo.io/ip), but that gave a different error:
WebSocket connection to 'wss://216.58.126.4:5000/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I've looked on the internet and all examples are structured exactly the same way as my test code so why is it not working?