0

I am able to use socket.io serving on localhost, connecting to namespaces and emitting messages etc. It is fully functioning. But when i deploy on Heroku, i experience that socket.emit does not work always, it sometimes works. Do i need to do something additional in order to make it work on Heroku?

Thank you in advance.

edit: after requesting socket.emit about 4 times in a row, it works everytime and emits. A stange behaviour..

Serhan Oztekin
  • 475
  • 7
  • 20

1 Answers1

0

Could it be as simple as your app is being moved to a different server/dyno in Heroku? When I first deployed apps there, it took a little while to sink in why sessions would disappear (I only held them in memory). Unless you're persisting something to let the next server that runs your app pick up from where the previous one left off, it can't maintain a connection. So, I suspect your problem will be solved in the same way as this answer, but you're not getting it for precisely the same reason.

This socket.io issue may give you some useful related information too

Community
  • 1
  • 1
Alex Taylor
  • 8,343
  • 4
  • 25
  • 40
  • 'The free and hobby dyno types only support a maximum of one dyno running per process type. Additionally, applications using a free dyno type are limited to a maximum of two concurrent running dynos.'-Heroku docs. I'm not sure whether there are concurrently running two dynos for 'socket.emit'. If that's the case, i guess i have to use https://github.com/socketio/socket.io-redis @Alex – Serhan Oztekin Oct 11 '15 at 13:42