I am using socket.io and using this guide to implement it and the server is able to start up with no errors. But whenever I try connecting to the WebSocket from the server I am getting an error similar to this: Did not receive a valid HTTP response
.
I am initializing socket.io with this code:
const socketio = new Server(http, {
serveClient: false,
pingInterval: 10000,
pingTimeout: 5000,
});
Edit:
I am trying to connect to the WebSocket with this URL:
ws://localhost:8000
using Python's WebSocket package. I used their example which is this:
import asyncio
import websockets
async def connect():
await websockets.connect("ws://localhost:8000")
asyncio.run(connect())
Edit I made it work by using the wss package instead
Check the port the server is listening to and match both client and server. You should avoid low ports because those are used for common known apps and your system may piss you off by using them. 5 digits should be enough