开发者

Node.js on Heroku with 2 ports

开发者 https://www.devze.com 2023-03-25 08:29 出处:网络
I\'m trying to p开发者_如何学运维ush a node.js app to heroku. The app has a http server listening on one port (process.env.PORT) but I also want a web socket using another port. Is this possible in h

I'm trying to p开发者_如何学运维ush a node.js app to heroku.

The app has a http server listening on one port (process.env.PORT) but I also want a web socket using another port. Is this possible in heroku? I am using ws.js to do the sockets.

On my local machine I can obviously use 3000 for one port and 8080 for the other, but I can't see how to define a second port that heroku will be happy to let me use.

thanks

matt


According to Heroku they don't yet support WebSockets: see this article. According to this SO question you can use socket.io (< v0.7) to do realtime stuff, but you can't use WebSockets, it'll fall back to XHR polling.


Heroku now supports websockets, as of 2013. For implementation have a look at the following article:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号