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

WebSocket Session Affinity Broken in Istio due to Missing Cookie/Header #1892

Open
munday-tech opened this issue Feb 14, 2025 · 2 comments
Open
Labels
bug Something isn't working needs-triage

Comments

@munday-tech
Copy link

munday-tech commented Feb 14, 2025

Issue

Last year, a change was made to remove X-Chainlit-Session-Id and other extraHeaders from WebSocket connections (see PR: #1575). The intention was to move towards cookie-based session affinity, but no cookie is currently being set to maintain this affinity.

Impact

For Istio-managed Kubernetes clusters, sticky sessions are broken because:

  • Istio relies on consistent hashing (ConsistentHashLB) to provide session affinity. Docs
  • This requires either a header or a cookie to consistently route WebSocket requests to the same pod.
  • Without a header/cookie, subsequent WebSocket connections get randomly load-balanced, leading to session disruptions.

Expected Behavior

  • A session cookie (e.g., X-Chainlit-Session-Id) should be set if headers are removed.

This would allow Istio to hash on the cookie and properly maintain sticky sessions.

@dosubot dosubot bot added the bug Something isn't working label Feb 14, 2025
@willydouhard
Copy link
Collaborator

My understanding is that is it up to the load balancer to set/read that cookie and not the application

@munday-tech
Copy link
Author

That applies if you're relying on an external load balancer for sessions. However, in our EKS deployment, Istio manages internal traffic instead of the ALB handling sticky sessions.

This basically means with the removal of headers and no addition of a session cookie, Chainlit just simply won't work in multi-pod deployments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants