Hi everyone,
I’m trying to make a websocketserver in python on replit.
Here’s my code :
import asyncio
import websockets
import json
import os
PORT = 8060
async def handler(websocket, path):
print("New connection")
data = await websocket.recv()
parsedData = json.loads(data)
print(parsedData)
async def main():
async with websockets.serve(handler,"0.0.0.0",PORT):
await asyncio.Future() # garde le serveur ouvert indéfiniment
asyncio.run(main())
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.