Unable to access MQTT Mosquitto Server

I am new to alot of this software so I apologize in advance if I am missing something simple. I have had no issue accessing NodeRED or OpenHab when searching my IP followed by :1880 or :8080, but when trying to access MQTT by using port:1883 my browser reads, “This site can’t be reached”. I have the pre-build emonPi SD installed so that shouldn’t be the issue. I am connected through WiFi and on the emonPi display it says MQTT is connected. I have also been struggling to connect the emonPi to NodeRED via MQTT, which I think is tied to this issue as well. Any help would be appreciated.

That is not how MQTT works. It does not have a web interface. Bit like SSH uses port 22.

What are you trying to do?

That makes a lot of sense. I am just struggling to get the emonpi to connect on NodeRED. In emoncms I have the process “edit to MQTT” with the text being:

emon/emonpi/power1

This is the third order after “log to feed” and “power to kwh”. In NodeRED I have the MQTT input block:

Broker: localhost: 1883
Topic: emon/emonpi/power1

I just have this connected to a Debug block right now to get the data to show, but when I deploy the MQTT block fails to connect. To give you a visual of where I am going with this I am basically just trying to forward the data from the emonPi over to Amazon Web Services. Thanks again for your help.

The emon base topic is the incoming topic to EmonCMS. Use a different base topic when setting up emoncms to send out values.

You will also need to put in user and password on Node-Red as the emonpi has these set in the broker by default. They are emonpi and emonpimqtt2016 respectively.

running

mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'

from the command line will show you data going into emoncms.

Change the base topic to see what is coming out.

I changed the base topic but nothing seemed to change. Do I have to change it to something in particular or could it be anything?

The password to get in to NodeRED was emonpi2016 for me, rather than emonpimqtt2016, not really sure if this is significant at all.

Lastly, how do I access the command line to be able to see the data going into CMS. Also why is it necessary to go through emoncms prior to getting the data in NodeRED? Won’t the emon base topic let me receive the data directly from the emonpi?

I don’t think it is necessary, what is consuming the data at AWS?

Do you also want the data locally on the emonPi or is that not needed?

OK so back to basics, If you run this command do you see the data?

mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'

If not, you need to work out what the right user/password option is before trying anything else.

If you do see the data, this is the data being passed from EmonHub, via the Mosquitto MQTT broker to EmonCMS (which is acrting as an MQTT Client) for processing (what you see as an input). Because this data transfer is using the MQTT protocol, any number of MQTT clients can connect to the broker and receive the data. However, the data is in a relatively raw form so depending on exactly what you are wanting to send to AWS you may have to process it through EmonCMS first.

NodeRED is a completely different application so it is not surprising it has a different password.

Sorry for the delayed response, but I was dealing with some network issues. During this time, another issue has arisen which seems crucial to fix before dealing with my NodeRED issue. MQTT is struggling to connect, with the display just reading, “Connecting, Please Wait” This is what is returned when i check the emonHub status:

$ sudo service emonhub status
● emonhub.service - LSB: Start/stop emonHub
   Loaded: loaded (/etc/init.d/emonhub)
   Active: active (exited) since Fri 2018-06-08 12:41:53 UTC; 10min ago
  Process: 22672 ExecStop=/etc/init.d/emonhub stop (code=exited, status=0/SUCCESS)
  Process: 22729 ExecStart=/etc/init.d/emonhub start (code=exited, status=0/SUCCESS)

Jun 08 12:41:53 emonpi sudo[22739]: pam_unix(sudo:session): session closed ...ot
Jun 08 12:41:53 emonpi sudo[22751]: root : TTY=unknown ; PWD=/ ; USER=root ...ub
Jun 08 12:41:53 emonpi sudo[22751]: pam_unix(sudo:session): session opened ...0)
Jun 08 12:41:53 emonpi sudo[22751]: pam_unix(sudo:session): session closed ...ot
Jun 08 12:41:53 emonpi sudo[22761]: root : TTY=unknown ; PWD=/ ; USER=root ...ub
Jun 08 12:41:53 emonpi sudo[22761]: pam_unix(sudo:session): session opened ...0)
Jun 08 12:41:53 emonpi sudo[22761]: pam_unix(sudo:session): session closed ...ot
Jun 08 12:41:53 emonpi systemd[1]: Started LSB: Start/stop emonHub.
Jun 08 12:41:53 emonpi emonhub[22729]: Starting OpenEnergyMonitor emonHub: ...k.
Jun 08 12:41:54 emonpi emonhub[22729]: Unable to load configuration file: /...nf
Hint: Some lines were ellipsized, use -l to show in full.

I then checked to see if emonHub is posting to MQTT and this is what was shown:

2018-06-08 11:39:45,945 CRITICAL MainThread Configuration file error - section: 'interfacers'

Here is the Emoncms MQTT Input Service status as well:

 mqtt_input.service - Emoncms MQTT Input Script
   Loaded: loaded (/etc/systemd/system/mqtt_input.service; enabled)
   Active: active (running) since Fri 2018-06-08 12:09:45 UTC; 48min ago
     Docs: https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
 Main PID: 17079 (php)
   CGroup: /system.slice/mqtt_input.service
           └─17079 /usr/bin/php /var/www/emoncms/scripts/phpmqtt_input.php

Jun 08 12:09:45 emonpi systemd[1]: Started Emoncms MQTT Input Script.

I do not see the data, but I also have never changed the username/password.

Did you get an error? Does it connect but just stay blank?

Actually I have just tried that command and got an error - it did not like the topic in quotes. The command should be

mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t emon/#

However, if emonHub is not running right now (according to your other post) I’d not expect to see data.

That username and password are the default for an EmonPi.

I ran both commands and they remained blank. Hopefully getting emonHub up and running again will solve this.

I am not really sure what is consuming the data at AWS and not really sure how to find out. Also it is not important to be able to store the data locally.

So after a quick factory reset MQTT is up and running again. If anyone has some knowledge as to why this happened in the first place I would like to avoid having to reset again if this were to happen in the future.

I ran the command and all that was returned was a continuous

Connection Refused: not authorised.

I was just trying to understand what “I am basically just trying to forward the data from the emonPi over to Amazon Web Services.” means exactly. Are you sending to an application or database? Are you just storing backup files? Is there an API you need to use or do you write a script that runs that end to convert or manage the incoming data? I’m not familiar with using AWS and it seems it can be many things from what I’ve read.

On the surface it looks like a simple password or username mismatch, but I’m sure you will have checked that several times.

Looking back a few posts I can see

2018-06-08 11:39:45,945 CRITICAL MainThread Configuration file error - section: 'interfacers'

from the emonhub.log and in the emonhub service status is has

Jun 08 12:41:53 emonpi emonhub[22729]: Starting OpenEnergyMonitor emonHub: ...k.
Jun 08 12:41:54 emonpi emonhub[22729]: Unable to load configuration file: /...nf

These errors are excatly as they say, the configuration file (emonhub.conf) couldn’t be loaded, this will be due to an edit that doesn’t conform with the requirements, perhaps the sub-section titles in [interfacers] were not unique? Or the mandatory [[[init_settings]]] and [[[runtimesettings]]] sections were not all there (even if empty) for each separate interfacer.

I am sending to a database. The plan is to have several IoT devices, with AWS acting as the central hub for all of the data. I figured NodeRED was the easiest way to accomplish this. There is an API I need to use, and I am able to connect using an output MQTT block and assigning certificate, private key, etc. It is just getting the emonPi to connect to a MQTT input block that I am currently having an issue with.