Local mqtt-gateway in 2022

Hi, I did my best to run my own mqtt-gateway.

Shortly: did someone run it in 2022 or still using it? I really need help with “Error starting Mosca Server”.

It seems this code comes from farmbot team. I have no idea why they did this in nodejs but OK is it cold be helpfull then no problem.
But it is not very helpful.

  1. First nodejs build errors. Last work on this was in 2017. So in combination with nodejs is this quite problem - ubuntu 22 respectively. It does match nothing so I got nice error generator. Finally I found nodejs version 8 match. And the build was done with last error whis I solved with help from stackoverflow.

  2. So can I be happy, no. I see another obscure error:

honza@honza-VirtualBox:~/mqtt-gateway$ WEB_API_URL=http://localhost:3000 sudo npm start
[sudo] password for honza:

> farmbot-mqtt-gateway@1.1.0 start /home/honza/mqtt-gateway
> nodemon ./app/index.js

[nodemon] 1.19.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./app/index.js`
Using http://localhost:3000 as API URL
{"pid":10241,"hostname":"honza-VirtualBox","name":"mosca","level":50,"time":1662391106351,"msg":"Error starting Mosca Server","v":1}
      throw er; // Unhandled 'error' event

Error: listen EADDRINUSE :::1883
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at Server.setupListenHandle [as _listen2] (net.js:1367:14)
    at listenInCluster (net.js:1408:12)
    at Server.listen (net.js:1492:7)
    at /home/honza/mqtt-gateway/node_modules/mosca/lib/server.js:225:16
    at makeCall (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:119:7)
    at NoResultsHolder.release (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:67:9)
    at series (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:39:14)
    at Object.eachSeries (/home/honza/mqtt-gateway/node_modules/steed/steed.js:47:5)
    at Server.steed.series.logInfo (/home/honza/mqtt-gateway/node_modules/mosca/lib/server.js:211:13)
    at makeCall (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:117:7)
    at ResultsHolder.release (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:96:9)
    at Server.steed.series.steed.eachSeries.fallback (/home/honza/mqtt-gateway/node_modules/mosca/lib/server.js:204:9)
    at makeCall (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:117:7)
    at ResultsHolder.release (/home/honza/mqtt-gateway/node_modules/fastseries/series.js:96:9)
    at /home/honza/mqtt-gateway/node_modules/ascoltatori/lib/ascoltatori.js:93:9
    at TrieAscoltatore.<anonymous> (/home/honza/mqtt-gateway/node_modules/ascoltatori/lib/abstract_ascoltatore.js:61:7)
    at emitTwo (events.js:126:13)
    at TrieAscoltatore.emit (events.js:214:7)
    at _addListener (events.js:249:14)
    at TrieAscoltatore.addListener (events.js:297:10)
[nodemon] app crashed - waiting for file changes before starting...

Did someone see this error. Has someone idea what is going on?

Thanks, Jan

Ok, I got it. The mqtt-gateway blames on port 1883 which is in use. The Farmbot-web-app says :

farmbot-web-app-mqtt-1 | 2022-09-05 21:25:05.048 [info] <0.443.0> started MQTT TCP Listener on [::]:1883

This is the problem. OK, seriously who is the server and who is the client ?


Btw good place to talk to your selves. I hope at least this could help to someone in future, maybe me again.

Hi me,
I am back. It seems is not expected to run the mqtt server on same machine as farmbot-web-app. You should try reaarange the ports somehow.

See me soon.

But “WEB_API_URL=http://localhost:3000” looks like it could…

It looks like there is no need for MQTT broker anymore. Like it is already part of the farmbot-web-app.

Have you tried the Docker Compose setup available here: Farmbot-Web-App/docker-compose.yml at staging · FarmBot/Farmbot-Web-App · GitHub to get your local instance setup? Most of what you need will be here and ready to run.

Hi stre1026,
sure I did run docker compose.

honza@honza-VirtualBox:~/Farmbot-Web-App$ history | grep “docker compose up”
77 sudo docker compose up
97 sudo docker compose up
136 sudo docker compose up
151 sudo docker compose up

It is mentioned in the Farmbot-Web-App/ubuntu_example.sh at main · FarmBot/Farmbot-Web-App · GitHub .
I did all what is mentioned in this script, all tests passed.
I just wonder there is not mentioned postgres installation. The installation instructions seems incomplete to me and the web application only silently failed. I’m not very used to such things.

In the api.Dockerfile ?

Thank you jsimmonds !
This means it is installed automatically.
Now I can confirm the db run.


The server is running, thank you for support!

I can confirm there is no need for MQTT installation or setup, all si done by the Farmbot-Web-App project automatically.

This thread can be closed now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.