TRANSPORT_HANDSHAKE_ERROR after upgrading to socket.io v4
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Description
Describe the bug
After upgrading to socket.io v4 from v2, our client and server connections no longer work correctly. We upgraded the socket.io-client package for the client to the latest version (4.7.3) and upgraded the socket.io server package to the latest version (4.7.3). After doing so, we receive TRANSPORT_HANDSHAKE_ERROR whenever trying to connect using a websocket transport. We are able to connect using polling but the websocket transport fails constantly. The connection appears to work locally without any issues but does not work when pushed to production. Our production infrastructure for the socket io logic consists of a single EC2 instance behind an Application Load Balancer. We route the requests on port 80 through an Apache reverse proxy to an instance within our VPC on port 4500. Once the request hits the socket io instance on port 4500, express and Node JS take over.
To Reproduce
Install latest version of socket.io-client and socket.io, run on an EC2 instance behind an application load balancer, attempt to connect using websocket as the primary transport. We've reproduced the issue using a socket.io-client in a React Native app and through the browser using Safari 16.6. The socket.io server runs Amazon Linux AMI 2 and we use Node JS and express to serve up the socket io application.
Expected behavior
The client and server should complete a handshake.
Platform:
-Safari 16.6
-iOS Simulator 17.0
-iPhone 15 Pro iOS 17.3
-Amazon Linux AMI 2
Additional context
Sharing code will be difficult due to the purpose of the code but I'm happy to do what I can to provide as much information as possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the websocket request through the AWS Application Load Balancer, the Apache reverse proxy on port 80, and the Express/Node.js server on port 4500, comparing it with the working polling path. Reproduce the connection failure in the stated production setup; done means the client and server complete a websocket handshake.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- apache, aws, express, nodejs, react-native, typescript
- Domain
- api, backend, cloud, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100