Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

476
Vistas
Why do i have the error WebSocket connection failed - socket.io

I'm working with socket.io in React JS (client) and Node JS (server), and when i deployed the apps i got WebSocket connection to 'wss://***.com:57284/ws' failed.

enter image description here

Running locally it dont happend and i'd like to know why and how to solve it.

This is the server code

const {Server} = require("socket.io");


const port = process.env.PORT || 5000
// io.listen(port);
console.log("Server listening on " + port)
const io = new Server(port, {
    cors: {
        origin: "https://***.com",
        methods: ["GET", "POST"]
    },
    path: "/api/",
});
io.on("connection", (socket) => {
***all socket logic***
});


and the client

  const [socket, setSocket] = useState(null)
  useEffect(() => {
    const newSocket = io("https://***.com", {transports: ['websocket'], path: "/api/"})
    setSocket(newSocket)
    return () => newSocket.close()
  }, [setSocket])

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda