Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

475
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!