• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

332
Vistas
WebSocket connection failed:

I am dealing with an error that says the web socket connection failed in my MERN web app. here is my server site code:

    const http = require('http')
    const { Server } = require("socket.io");
    const app = express();
    app.use(cors());

    let server = http.createServer(app)

    const io = new Server(server, {
      cors: {
        origin: `${process.env.MYBIYESADI}`
      },
      allowEIO3: true
    })
    io.on("connection", function (socket) {
    console.log("a user connected.")
   socket.on("disconnect", () => {
        console.log("a user disconnected!")
        io.emit("onlineUsers", users)
    })
  })

and frontend site code is:

import { io } from "socket.io-client";
const socket = useRef()
useEffect(() => {
    socket.current = io(`${process.env.REACT_APP_API_URL}`, { transports: ["websocket"] })
  }, [])

What's not written as expected? Its working fine locally and I have hosted both in wss and https as in URL but after hosting to aws docker it shows that wss connection failed as

2.647cd368.chunk.js:2 WebSocket connection to 'wss://url/socket.io/?EIO=4&transport=websocket' failed:

about 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda