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

227
Vistas
How to get sockets working with Gatsby v4?

After recenty upgrading Gatsby from v2 to v4, I am unable to get my socket client to connect.

In my Gatsby app, I have the following to connect to my staging socket server (which is working with my v2 version of gatsby)

const socketClient = io(window.apiEndpoint, {
  query: {
    clientId,
  },
});
console.log("socketClient:", socketClient.connected) // false

I have tried adding a listener for connection errors like so:

socketClient.on("connect_error", (err) => {
  console.log(err); // server error
});

But only get the error server error.

I know my server is working fine because it works with my previous version of the app.

Is there a way to get more details on the error?

I can also see in my network tab that there are a bunch of network requests like so:

Request URL: ws://localhost:58881/socket.io/?EIO=4&transport=websocket&sid=u3YuZeAifJYOICpNAAAE
Request Method: GET
Status Code: 101 Switching Protocols

and

Request URL: ws://localhost:8000/socket.io/?EIO=4&transport=websocket
Request Method: GET
Status Code: 101 Switching Protocols

Why do these point to localhost if my socket server is pointing to an external URL?

Any debugging tips to try and get more details on the error or understand why the socket client is polling ws://localhost... would be greatly appreciated.

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