1

So I basically wanted to host a mqtt pub/sub-enabled node server on Heroku. These are 2 guides I refer to: https://github.com/adamvr/MQTT.js and https://gist.github.com/1826931

The mqtt pub/sub worked well when tested on localhost, deployment on heroku was fine, but when I tried testing on Heroku it didn't work

I tried 2 commands to subscribe, both showed the same errors.

Command 1:

mosquitto_sub -p <port> -h <host> -t <topic>

Error 1:

Error: Connection refused
Unable to connect (13).

Command 2:

mqtt_sub <port> <host> <topic>

Error 2:

node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: connect ECONNREFUSED
    at errnoException (net.js:670:11)
    at Object.afterConnect [as oncomplete] (net.js:661:19)

My main.js (server) code is similar to this one - https://gist.github.com/1826931. The error seems more like a node problem than a mqtt pub/sub problem, and I am new to node, so not quite sure how to debug it. I put in some console.log lines but as expected it didn't print since it's not connected. There is a dyno running node main.js on Heroku fine.

Process  State       Command       
-------  ----------  ------------  
web.1    up for 35m  node main.js

Appreciate any advice on this issue.

1
  • I'm not sure what exactly Heroku is and how does it work, but did you make sure that the port you are using is indeed open on the server?
    – Dror
    Apr 4, 2012 at 13:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.