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

220
Views
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
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!