Skip to content

Instantly share code, notes, and snippets.

@ReidCarlberg
Created December 28, 2013 12:56
Show Gist options
  • Save ReidCarlberg/8159242 to your computer and use it in GitHub Desktop.
Save ReidCarlberg/8159242 to your computer and use it in GitHub Desktop.
Challenge: deploy node-red to a heroku endpoint.
2013/12/27
First challenge -- you have to have red.js listen on process.env.PORT rather than 1880.
https://devcenter.heroku.com/articles/getting-started-with-nodejs
Second challenge -- web sockets -- node-red uses web sockets, so the server comes up and disconnects right away.
When you enable the lab:websockets it doesn't fix it out of the box.
https://blog.heroku.com/archives/2013/10/8/websockets-public-beta
@kmizuno
Copy link

kmizuno commented Mar 30, 2014

Could you let me know how to specify process.env.PORT on red.js to make it run on Heroku? I am trying to do it but I have not succeeded yet.
I am trying to work on the line below . Thanks. Katz
settings.uiPort = settings.uiPort||1880;

@theophoric
Copy link

settings.js:18 :: uiPort: process.env.PORT || 1880,

@theophoric
Copy link

Any luck on figuring out those websockets ?

@vielmetti
Copy link

Have you had any joy with this effort? Trying to do the same myself.

@bradeew-public
Copy link

Not sure when Heroku added web sockets, but now it works - see https://devcenter.heroku.com/articles/websockets for some info.

I was able to get it up and running using the line:
settings.uiPort = (process.env.PORT || 1880);
in red.js

@aniston
Copy link

aniston commented Nov 26, 2014

EDIT:
Added a Procfile to include:
web: node red.js

Then did exactly as you said above:
Modified file red.js with:
settings.uiPort = (process.env.PORT || 1880);

and then did a git commit and then push
git commit -am "modified file red.js"
git push heroku master

after that it worked, sorry for the confusion, but I was missing your mod and the Procfile.

Bradeew, can you show us in simple steps how you were able to get node-red on heroku working ?
My simple git clone of node-red fails just after the main interface loads up , I keep getting "Error connecting to the server" just after the main interface borders show and the left hand korner vertical bars are running (node-red MENU is available on the right too) but no left menu and the error message at the top does not go away.
Maybe I'm missing an index.js file declaration. any help would be appreciated.

@nemoDreamer
Copy link

Hi folks, @bradeew, @aniston,
still trying to get Node-Red running on Heroku.

My DIFF so far:

diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..f94c2fa
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: node red.js
diff --git a/settings.js b/settings.js
index 28782c0..98dd0cc 100644
--- a/settings.js
+++ b/settings.js
@@ -20,7 +20,7 @@

 module.exports = {
     // the tcp port that the Node-RED web server is listening on
-    uiPort: 1880,
+    uiPort: process.env.PORT || 1880,

     // By default, the Node-RED UI accepts connections on all IPv4 interfaces.
     // The following property can be used to listen on a specific interface. For
@@ -93,7 +93,10 @@ module.exports = {

     // The following property can be used in place of 'httpAdminAuth' and 'httpNodeAuth',
     // to apply the same authentication to both parts.
-    //httpAuth: {user:"user",pass:"5f4dcc3b5aa765d61d8327deb882cf99"},
+    // httpAuth: {
+    //     user: process.env.BASIC_AUTH_USER || "user",
+    //     pass: process.env.BASIC_AUTH_PASS || "5f4dcc3b5aa765d61d8327deb882cf99"
+    // },

     // The following property can be used to disable the editor. The admin API
     // is not affected by this option. To disable both the editor and the admin

(I don't think I need the httpAuth stuff yet, right?)

Is this PORT env variable pre-set by Heroku? Or is this a Heroku Config Var I need to manually set? If yes, to what value?

Do I need to modify uiHost, userDir or nodesDir?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment