Socket.io connecting/disconnecting unexpectedly in production - MEAN stack hosted on Elastic Beanstalk #4296
Unanswered
mazenhilal
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a MEAN stack application hosted on AWS Elastic Beanstalk that uses socket.io This socket.io is connecting/disconnecting unexpectedly.
The socket causes a code of 4xx to the server. After a few 4xx are sent to AWS, the server degrades automatically and the socket disconnects. So it becomes like a loop, AWS first receives the 4xx, then the environment becomes unhealthy, then the socket behaves even more strange because the server is about to go down, etc.
What matters is that the starting point is the 4xx caused by the socket.
The log I have says:
"GET /socket.io/?EIO=3&transport=polling&t=Nx_u0FB HTTP/1.1" 400 62
I tried to add the CORS option to the socket with the app domain as the origin, but it didn't help. Please note that this happens in production only and not on localhost.
Also, please note that this case doesn't happen unless we have like 10-20 users/sockets connecting from different parts of the world. If we have a few sockets, it rarely happens, and sometimes even if we have many users connecting from the same country, it doesn't happen. The behavior is very random.
Finally, I tried both the socket.io 2.4.1 & socket.io-client 2.4.0 and tried to migrate to socket.io 4.4.1 for both the client and server-side but nothing changed. The error in production is same for all cases.
Anyone can help with this?
Beta Was this translation helpful? Give feedback.
All reactions