1

I'm trying to make my node application working on heroku, and i stumble upon a, i'm sure common problem, but, i can't sort it out.

my project is a 3 part system, composed of :

  • a server file running express and socket.io
  • a "web app" in the public folder of the express node server
  • a stand alone node app, runned on my comp, linked to an arduino board

on my computer everything runs fine, since everybody listen to the node server from the same ip/port. but in herku since the port is dynamic, i can't get the two other components to know where to connect to.

i define my port like this :

var port = process.env.PORT || 5000;

and log the port on server up via a console.log statement.

after checking my logs a few time, and then looked at the heroku doc, i realised that i can't have a static port on heroku.

So i'm kind of lost on how can i get the two other component to get heroku port.

side note : here are the solution i will try to implement if i can't get it to work

  1. separate the web server and the io server so i can listen to the IO server itself, this solution IS working, but i would prefer having only one heroku instance running for that
  2. make the io server listening to the express server event, it should work ... but this is not solving the issue for the part on my computer.
  3. jump of a big bridge, resolve no issue, but will make the issues less important.

thanks for the time you spent reading my existentials problems, and thanks in advance for the help

4

1 回答 1

2

要将外部应用程序连接到 heroku 应用程序,您无需知道端口。由于可以通过域名访问该应用程序,因此您可以简单地连接到该应用程序(例如app_name.herokuapps.com,如果您愿意,也可以获取自己的域)。

于 2013-06-17T13:36:37.273 回答