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

210
Vistas
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
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