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

104
Vistas
Get response headers from websocket handshake

I'm trying to get a client to read the error message given when a connection to a WebSocket is failed. The client attempts to connect to the socket with

this.socket = new WebSocket(url);

and the server handles this by listening for

server.on('upgrade', function upgrade(request, socket, head) {...})

If the client doesn't have the proper authentication, the server sends socket.write with a 401 error and a custom header containing a message saying why the connection failed, and then doing a socket.destroy(). After this, the client's this.socket is set to null as it isn't opened.

My question is, how can I get the client to read that custom error message so that I can display it to the user? If this isn't possible, what would be the best approach to communicate this error?

about 4 years ago · Santiago Trujillo
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