Node.js on Heroku with 2 ports

I am trying to push a node.js application on heroku.

The application has an HTTP server listening on one port (process.env.PORT), but I also want the web socket to use a different port. Is this possible in heroics? I use ws.js to create sockets.

On my local machine, I obviously can use 3000 for one port and 8080 for another, but I don’t see how to determine the second port, which the hero will be happy to let me use.

thanks

matte

+7
source share
2 answers

According to Heroku, they do not yet support WebSockets: see this article . According to this SO question, you can use socket.io (<v0.7) to work in real time, but you can’t use WebSockets, it will fall off to the XHR poll.

+2
source

Heroku now supports websockets starting in 2013. For implementation, consider the following article:

https://devcenter.heroku.com/articles/node-websockets

+2
source

All Articles