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

213
Views
Socket.IO : connect_error event not emitted

i have a simple socket.IO server, and a client that connects to it :

    socket = io('http://localhost:' + port + '/chat', {
        reconnection: false,
        query: {
            name: username
        }
    })

it works perfectly fine, but when i tried implementing the behavior of that client when the server cannot be found (which i simply test by just loading the page without starting the server), i faced a simple issue : the connect_error event is not emitter. Right after i initialize the socket, i have this code :

socket.on('connect_error', ()=>{
    console.log("Error! ")
})

as i said, this callback is never called, i get an error message in the console stating that the request returned 404 (http://localhost:5454/socket.io/?name=AA&EIO=4&transport=polling&t=O2__7JM), but my custom error message is never printed.
So, what am i doing wrong ? Isn't this event supposed to be fired if the connection with the server couldn't be established ? If not, how do i handle this situation (i.e. how do i make socket.io call a certain callback if the connection failed ?)

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!