Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting HTTP error 400 #4881

Open
moxpatwa opened this issue Nov 27, 2023 · 14 comments
Open

Getting HTTP error 400 #4881

moxpatwa opened this issue Nov 27, 2023 · 14 comments

Comments

@moxpatwa
Copy link

Hello,

I am getting HTTP Error 400 around.

I am using socket-io 4.7.2 and socket-io-client 4.7.2 and I am using react for front end this is my client side settings
Test png

in server side using node is which setting describe below:
Test02 png

Can you suggest me solutions for that?

Originally posted by @moxpatwa in socketio/socket.io-client#1474 (comment)

@moxpatwa
Copy link
Author

moxpatwa commented Nov 28, 2023

@stouset Any update on above issue

@moxpatwa
Copy link
Author

moxpatwa commented Dec 5, 2023

@dshaw and @darrachequesne any update on above issue.

@darrachequesne
Copy link
Member

Hi! HTTP 400 status usually means sticky sessions are not enabled properly, could you please check?

Reference: https://socket.io/docs/v4/using-multiple-nodes/

@moxpatwa
Copy link
Author

moxpatwa commented Dec 6, 2023

Thanks @darrachequesne .. i will try enable sticky session and let you if i still facing same issue or not.

@moxpatwa
Copy link
Author

moxpatwa commented Dec 7, 2023

@darrachequesne I am using node.js for service and react for frontend.. to enable sticky connection can you suggenst me best approach as our nodejs service are contains some rest endpoints ,schedules some job, socketio events.
To enable sticky i have made below change in server file
image
and client side code is below:
image
After making these change still getting session is unknown error. let me guide on this.

@fillipearaujo
Copy link

For those who are having trouble with sticky session polling on a Kubernetes server. Below is an example of annotations declaration in ingress.yaml to enable the sticky session.

Status: 400
Error: {"code":1,"message":"Session ID unknown"}

   annotations:
     kubernetes.io/ingress.class: nginx
     nginx.ingress.kubernetes.io/affinity: "cookie"
     nginx.ingress.kubernetes.io/session-cookie-name: "route"
     nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"

@moxpatwa
Copy link
Author

moxpatwa commented Dec 7, 2023

@fillipearaujo Thank for reply but we are creating docker image of nodejs service and deploy and run via aws ec2 instance docker container.

@moxpatwa
Copy link
Author

moxpatwa commented Dec 8, 2023

@darrachequesne Any update on issue because it is impact our RTD app. Really appreciate your help on this

@moxpatwa
Copy link
Author

@darrachequesne Any update on above issue?

@darrachequesne
Copy link
Member

@moxpatwa sticky sessions are needed in case you have multiple Socket.IO server (for example when running with pm2). Is that your case?

See also: https://socket.io/docs/v4/troubleshooting-connection-issues/

@moxpatwa
Copy link
Author

moxpatwa commented Feb 5, 2024

@darrachequesne No we dont multiple Socket.io server.

@darrachequesne
Copy link
Member

I see you set pingTimeout to 6000 (6 seconds), which might be a bit low on mobile networks. If the client does not respond to the health check in the given delay, then the connection will be closed. Any reason for not using the default value?

Reference: https://socket.io/docs/v4/server-options/#pingtimeout

@moxpatwa
Copy link
Author

moxpatwa commented Feb 5, 2024

@darrachequesne Actually i have update code with below

image

But still facing Session ID unknown error

@darrachequesne
Copy link
Member

I'm out of ideas then... "Session ID unknown" means the session ID is not recognized by the server, which is usually caused by:

  • reaching another Socket.IO server which does not know the session (but this does not seem to be your case)
  • a failed health check, and the connection was closed with a "ping timeout" error

Do you get a "disconnect" event?

socket.on("disconnect", (reason, details) => {
  // the reason of the disconnection, for example "transport error"
  console.log(reason);

  // the low-level reason of the disconnection, for example "xhr post error"
  console.log(details.message);

  // some additional description, for example the status code of the HTTP response
  console.log(details.description);

  // some additional context, for example the XMLHttpRequest object
  console.log(details.context);
});

Reference: https://socket.io/docs/v4/troubleshooting-connection-issues/#problem-the-socket-gets-disconnected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants