Hi, I’m Dung Huynh Duc . Nice to meet you.

About Me

With over a decade of experience under my belt as a full-stack developer, I've had the opportunity to spearhead project teams at tech startups in Vietnam, Thailand, Japan and Singapore. Additionally, I have worked as a freelance engineer for various companies based in Asia Pacific, Europe, and North America.

Presently, I serve the role of a Senior Full Stack Software Engineer at ACX. I am consistently committed to exploring and acquiring knowledge on emerging and popular technologies.

Session ID unknown

#TIL 37 - How to fix Session ID unknown with socket.io

blog_hero_#TIL 37 - How to fix Session ID unknown with socket.io

If you're using Socket.io in your web application, you may encounter an issue where the Session ID is unknown. The solution is disabling HTTP long-polling and using only WebSockets for communication between the client and server.

// client-side
const socket = io({
  transports: ["websocket"] // HTTP long-polling is disabled

The root cause is enabling "sticky session" if HTTP long-polling is enabled (which is the default). You can read more about why sticky sessions are required and how to implement them in the Socket.io documentation: https://socket.io/docs/v4/using-multiple-nodes/#why-is-sticky-session-required