I have a python websockets since a year or two, i usually have two clients connecting, one using C# and one using python.
I recently started working on a web client and try to use JS Websocket and it’s throwing an error :
Firefox can’t establish a connection to the server at wss://*url removed for privacy*/.
Same with Chrome :
WebSocket connection to 'wss://*url removed for privacy*/' failed
This is what i have server side :
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_cert = "*path to cert*"
ssl_key = "*path to key*"
ssl_context.load_cert_chain(ssl_cert, keyfile=ssl_key)
async def main():
async with websockets.serve(echo, "0.0.0.0", 465, ssl=ssl_context):
print(f'Listening on port 465')
await asyncio.Future()
I can share the echo function if needed
This is my python code for connecting :
async with websockets.connect("wss://*URL removed for privacy*") as websocket:
await websocket.send('*data sent*')
response = await websocket.recv()
Working fine
On my C# client :
wsc = new WebsocketClient('wss://*URL Removed for privacy*');
wsc.ReconnectTimeout = TimeSpan.FromSeconds(15);
wsc.ReconnectionHappened.Subscribe(info => Console.WriteLine($"Reconnection happened, type: {info.Type}"));
await wsc.Start();
Working fine
And JS client :
const socket = new WebSocket("wss://*URL Removed for privacy*");
socket.addEventListener("open", (event) => {
socket.send("*data sent*");
});
Throwing an error
I don’t even know why it doesn’t connect as there’s no details on what’s going on with the connexion try.
Thanks for your help