Socket.io connection failed error. Need Help BADLY #4297
-
I've spent hours and hours on this but I can't figure out whats wrong.
Socket.io versionsServer Error on browser console
Serverconst app = express();
const server = http.createServer(app);
// Initialize socket.io
const io = new Server(server, {
cors: {
origin: "https://website.tk/",
methods: ["GET", "POST"],
credentials: true
}
})
// Cross Origin Resource Sharing (CORS)
app.use(cors({
origin: 'https://website.tk/',
credentials: true
}));
.
.
.
server.listen(4000, () => {
console.log("Server is running on port http://localhost:4000");
}); Clientconst socket = socketIOClient("https://website.tk/", {
withCredentials: true,
rejectUnauthorized: false // For testing, Didn't fix it.
});
socket.on("connect_error", (err) => {
console.log(`connect_error due to ${err.message}`);
console.log(err)
}); CaddyFile
If you need more information, just ask. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! According to |
Beta Was this translation helpful? Give feedback.
Hi! According to
wss://website.tk:3000/ws
, it seems you are using a custom path (the default path is/socket.io
). Are you using the same value for the server and the client?Reference: https://socket.io/docs/v4/client-options/#path