nguyenthanhson's avatar

Fix error WebSocket connection to 'wss://omegae.online/ws' failed

Fix error WebSocket connection to 'wss://omegae.online/ws'

Hi everyone,

I need assistance with a WebSocket connection issue between my frontend(omegae.online) and Socket.IO(socket.omegae.online) server. Here’s a brief overview of my setup and the problem I'm facing:

Project Overview: Frontend Project:

Port: 3000 Purpose: Serves the React application. Nginx Configuration:

**Socket.IO Server: ** Port: 4000 Purpose: Handles WebSocket connections. Nginx Configuration:

Code Config Socket:

const socketIO = require("socket.io");
const http = require("http");
const express = require("express");
const cors = require("cors");
const app = express();
const server = http.createServer(app);

const io = socketIO(server, {
    cors: {
        origin: "*",
        methods: ["GET", "POST"],
        credentials: true
    },
    transports: ["websocket", "polling"] 
});

require("dotenv").config({
  path: "./.env",
});

app.use(cors());
app.use(express.json());

app.get("/", (req, res) => {
  res.send("Hello world from socket server!");
});

Issue Encountered: Error Message: WebSocket connection to 'wss://omegae.online/ws' failed Steps Taken: Verified that both the frontend and Socket.IO server are running. Confirmed that the WebSocket server is listening on port 4000. Checked Nginx configurations for both the frontend and WebSocket server to ensure correct proxy settings. Used browser developer tools to inspect WebSocket errors and responses. Could you please help me diagnose and resolve this issue? If there are any additional details or configurations you need, please let me know.

Thank you for your assistance!

0 likes
0 replies

Please or to participate in this conversation.