Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

221
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda