I’m trying to make a websocketserver in python on replit.
Here’s my code :
PORT = 8060
async def handler(websocket, path):
data = await websocket.recv()
parsedData = json.loads(data)
async def main():
async with websockets.serve(handler,"0.0.0.0",PORT):
await asyncio.Future() # garde le serveur ouvert indéfiniment
Normally, it should work because the preview starts (as soon as a port is open) and i get that message :
Failed to open a WebSocket connection: empty Connection header.
You cannot access a WebSocket server directly with a browser. You need a WebSocket >client.
I have tried to connect with these urls:
It’s not working …
Could someone help me ?
Click Tools > Settings > Automatically open Webview when a port is open > disabled
How did you try connecting? You can’t go to them in your browser, you need to use JS or another python script,
The issue is not about that
I tried in js with :
const client = new Websocket(link)
Did it not work? What errors did you get (JS side).
Can you also link your repl?
I just had a sort of timeout message at the end of 30s a failure message.
Here’s the link :
Is your server running? Did you send any messages to the ws to test?
Did you try this URL with JS?
hey there, could you post the js client you’re using
I think they are just using native WS lib.
oh I see, I popped some similar code in and connected via
wss://url and it connected just fine, no stalling
Yeah I m using the native one
What’s the difference with the code ?
Nothing really… It was just a diff project with same base code
I think the implication might be that they tried replacing link with all four links referenced in the original post?
not sure whether it’s a typo, nor where you’re getting this error, but it’s
That link worked for 10min but it’s not anymore. It’s so random