question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sticky sessions not working when using Primus.createSocket - using engine.io transfomer

See original GitHub issue

Version: 5.0.1

Server Environment:

  • Operating system: Debian wheezy
  • Browser: no
  • Node.js: 4.2.2
  • Transformer: engine.io 1.6.8

Client Environment:

  • Operating system: OSX 10.10.5
  • Browser: no
  • Node.js: 4.2.2
  • Transformer: engine.io 1.6.8

Expected result: when using the primus client from node ( via Primus.createSocket ) it should handle sticky sessions over haproxy loadbalancer the same way as the browser client

Actual result: If I run two instances of primus on a remote server (lets say on port 1112 and 1113), behind a haproxy, the browser client connects to the instance, where the haproxy directs it, (lets say it connects to 1112) and it stays there, the sticky session is working

If I do the same from node, using Primus.createSocket, I can see the connection starts on one instance ( on port 1112) then the second or third, or nth packet hits the other instance ( on port 1113) and the client receives an error:

[Error: xhr poll error] type: 'TransportError', description: 400

This cannot be reproduced using the “websockets” transformer, so I’m unsure if it’s directly engine.io related.

Steps to reproduce: run two instances, with engine.io behind a haproxy, and try to connect them from node using Primus.createSocket

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
necccccommented, Jul 4, 2016

I’ve put my workaround in a module if anyone needs it in the future

https://github.com/necccc/primus-headless-cookie

0reactions
lpincacommented, Jun 28, 2016

Ok, thanks for the update. I close this, please post back if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.io 'Handshake' failing with cluster and sticky-session
I am having problems getting the sticky-sessions socket.io module to work properly with even a simple example. Following the very minimal ...
Read more >
primus
Transformer should close connection. Primus has ended. The underlaying connection is closed, we might retry. We received a new connection.
Read more >
primus-headless-cookie - npm Package Health Analysis - Snyk
This workaround solves the problem with loadbalancers, like haproxy, which commonly uses cookies for sticky sessions. FAQs. What is primus- ...
Read more >
nginx sticky sessions / ip_hash with Socket.io - Server Fault
I am to be load balancing two node.js/Socket.io instances on different boxes with nginx running a simple notifications service with a ...
Read more >
Primus | npm.io
primus-client-webpack-plugin, primus-headless-cookie, primus-mongodb, ... createSocket to handle sticky sessions & cookies ... Not for direct use.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found