Answer the question
In order to leave comments, you need to log in
Security websocket JS with Python?
Good afternoon!
There is a websocket server in python3 and a client in JS
The usual connection ws://localhost:8765 connects and works on the localhost, but it does not work on a VPS with HTTPS
Server example:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(certfile="/etc/letsencrypt/live/mysite.ru/fullchain.pem", keyfile="/etc/letsencrypt/live/mysite.ru/privkey.pem")
start_server = websockets.serve(server.ws_handler, 'localhost', 8765, ssl=ssl_context)
localhost_pem = Path(__file__ + "/../ssl/certificate.pem").resolve()
localhost_key = Path(__file__ + "/../ssl/key.pem").resolve()
socket = new WebSocket("wss://"+location.host+":8765");
Answer the question
In order to leave comments, you need to log in
I'm certainly not an expert, but it's logical to assume
start_server = websockets.serve(server.ws_handler, 'localhost', 8765, ssl=ssl_context)
that you cannot connect to localhost from outside, try replacing localhost with 0.0.0.0 Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question