# MQTT no longer working after update from emonSD-03May16 to most current version

**URL:** <https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578>\
**Category:** emonPi\
**Tags:** mqtt\
**Created:** [6 November 2017 13:42 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578 "2017-11-06T13:42:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [6 November 2017 13:42 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/1 "2017-11-06T13:42:23Z")

</div>

MQTT no longer working after I updated from emonSD-03May16- RELEASE to most current version. I followed these instructions;

You will get all the important security updates and Emoncms updates by running:  
Admin \> emonpiupdate in local Emoncms and upgrading Debian packages

```auto
rpi-rw
sudo apt-get update && sudo apt-get upgrade
sudo apt-get dist-upgrade 
sudo reboot

```

When given the option choose to keep the version of php.ini currently installed

Not sure what to try next ??

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [6 November 2017 16:39 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/2 "2017-11-06T16:39:08Z")

</div>

Have you also ran emonPi update?

Login to local Emoncms e.g. [http://emonpi.local/emoncms](http://emonpi.local/emoncms)  
Then select Setup \> Admin \> emonPi update  
Wait for it to finish then reboot the system.

Its it’s still not working please post your emonhub log file. This can be downloaded from the Setup \> emonHub section of local Emoncms.

---

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [6 November 2017 21:37 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/3 "2017-11-06T21:37:56Z")

</div>

Hi Glyn,

Yes I ran emonpi update and then;

```auto
rpi-rw
sudo apt-get update && sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo reboot

```

Note: I never saw this option on the update “When given the option choose to keep the version of php.ini currently installed”

this is from emonhub log file

```auto
2017-11-06 21:18:11.918|WARN|phpmqtt_input.php|Starting MQTT Input script
2017-11-06 21:30:42.130|WARN|phpmqtt_input.php|Not connected, retrying connection
2017-11-06 21:30:45.047|WARN|phpmqtt_input.php|Starting MQTT Input script
2017-11-06 21:30:46.193|WARN|phpmqtt_input.php|Not connected, retrying connection
2017-11-06 21:30:52.001|WARN|phpmqtt_input.php|Not connected, retrying connection
2017-11-06 21:30:58.001|WARN|phpmqtt_input.php|Not connected, retrying connection
2017-11-06 21:31:04.001|WARN|phpmqtt_input.php|Not connected, retrying connection
2017-11-06 21:31:10.000|WARN|phpmqtt_input.php|Not connected, retrying connection

```

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [7 November 2017 16:30 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/4 "2017-11-07T16:30:56Z")

</div>

> [@cormad](#):
>
> this is from emonhub log file
> 
> 2017-11-06 21:18:11.918|WARN|phpmqtt\_input.php|Starting MQTT Input script
> 
> 2017-11-06 21:30:42.130|WARN|phpmqtt\_input.php|Not connected, retrying connection
> 
> 2017-11-06 21:30:45.047|WARN|phpmqtt\_input.php|Starting MQTT Input script
> 
> 2017-11-06 21:30:46.193|WARN|phpmqtt\_input.php|Not connected, retrying connection
> 
> 2017-11-06 21:30:52.001|WARN|phpmqtt\_input.php|Not connected, retrying connection
> 
> 2017-11-06 21:30:58.001|WARN|phpmqtt\_input.php|Not connected, retrying connection
> 
> 2017-11-06 21:31:04.001|WARN|phpmqtt\_input.php|Not connected, retrying connection
> 
> 2017-11-06 21:31:10.000|WARN|phpmqtt\_input.php|Not connected, retrying connection

That is actually the emoncms log file. Cold you post to emonhub log file?

It seems there is an issue with MQTT. How difficult would it be to give me SSH access? This could be done using [https://www.dataplicity.com/](https://www.dataplicity.com/) if you don’t want to port forward?

Alternatively the next step would be to figure out why MQTT service us not running:

`sudo service mosquitto status `

---

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [7 November 2017 19:00 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/5 "2017-11-07T19:00:52Z")

</div>

Hi Glyn,

I have no issue giving you SSH access, just need to figure out how. I’m in the eastern standard time zone. I will post the emonhub log file tonight and also check the status.

---

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [7 November 2017 21:32 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/6 "2017-11-07T21:32:02Z")

</div>

Hi Glyn,  
Info from sudo service mosquitto status

```nohighlight
pi@emonpi(ro):~$ sudo service mosquitto status -1
● mosquitto.service - Mosquitto MQTT Broker
  Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled)
  Active: failed (Result: start-limit) since Mon 2017-11-06 21:43:53 UTC; 23h ago
    Docs: man:mosquitto(8)
          https://mosquitto.org/
 Process: 678 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 678 (code=exited, status=1/FAILURE)

Nov 06 21:43:53 emonpi systemd[1]: Unit mosquitto.service entered failed state.
Nov 06 21:43:53 emonpi systemd[1]: mosquitto.service holdoff time over, scheduling restart.
Nov 06 21:43:53 emonpi systemd[1]: Stopping Mosquitto MQTT Broker...
Nov 06 21:43:53 emonpi systemd[1]: Starting Mosquitto MQTT Broker...
Nov 06 21:43:53 emonpi systemd[1]: mosquitto.service start request repeated too quickly, refusing to start.
Nov 06 21:43:53 emonpi systemd[1]: Failed to start Mosquitto MQTT Broker.
Nov 06 21:43:53 emonpi systemd[1]: Unit mosquitto.service entered failed state.
Nov 06 21:44:00 emonpi systemd[1]: Starting Mosquitto MQTT Broker...
Nov 06 21:44:00 emonpi systemd[1]: mosquitto.service start request repeated too quickly, refusing to start.
Nov 06 21:44:00 emonpi systemd[1]: Failed to start Mosquitto MQTT Broker.
pi@emonpi(ro):~$

```

---

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [7 November 2017 21:37 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/7 "2017-11-07T21:37:51Z")

</div>

Hey Glyn,

emonhub log file

```nohighlight
2017-11-07 21:34:17,728 INFO MQTT Could not connect...
2017-11-07 21:34:18,053 DEBUG MainThread SIGINT received.
2017-11-07 21:34:18,053 INFO MainThread Exiting hub...
2017-11-07 21:34:18,730 INFO MainThread Exit completed
2017-11-07 21:34:19,437 INFO MainThread EmonHub emonHub emon-pi variant v2.0.0
2017-11-07 21:34:19,437 INFO MainThread Opening hub...
2017-11-07 21:34:19,438 INFO MainThread Logging level set to DEBUG
2017-11-07 21:34:19,438 INFO MainThread Creating EmonHubJeeInterfacer 'RFM2Pi' 
2017-11-07 21:34:19,440 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 38400 bits/s
2017-11-07 21:34:21,442 WARNING MainThread Device communication error - check settings
2017-11-07 21:34:21,444 INFO MainThread Setting RFM2Pi frequency: 433 (4b)
2017-11-07 21:34:22,446 INFO MainThread Setting RFM2Pi group: 210 (210g)
2017-11-07 21:34:23,448 INFO MainThread Setting RFM2Pi quiet: 0 (0q)
2017-11-07 21:34:24,449 INFO MainThread Setting RFM2Pi baseid: 5 (5i)
2017-11-07 21:34:25,451 INFO MainThread Setting RFM2Pi calibration: 110V (2p)
2017-11-07 21:34:26,454 DEBUG MainThread Setting RFM2Pi subchannels: ['ToRFM12']
2017-11-07 21:34:26,455 DEBUG MainThread Setting RFM2Pi pubchannels: ['ToEmonCMS']
2017-11-07 21:34:26,456 INFO MainThread Creating EmonHubMqttInterfacer 'MQTT' 
2017-11-07 21:34:26,457 INFO MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883 mqtt_user=emonpi
2017-11-07 21:34:26,460 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg' 
2017-11-07 21:34:26,561 INFO MQTT Connecting to MQTT Server
2017-11-07 21:34:26,563 INFO MQTT Could not connect...
2017-11-07 21:34:27,665 INFO MQTT Connecting to MQTT Server
2017-11-07 21:34:27,667 INFO MQTT Could not connect...
2017-11-07 21:34:28,769 INFO MQTT Connecting to MQTT Server
2017-11-07 21:34:28,770 INFO MQTT Could not connect...
2017-11-07 21:34:29,872 INFO MQTT Connecting to MQTT Server

```

---

<div class="post-metadata">

**Author:** ![jsroques](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jsroques](https://community.openenergymonitor.org/u/jsroques)\
**Post date:** [7 November 2017 22:31 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/8 "2017-11-07T22:31:59Z")

</div>

Hello,

Just created another post about the same problem here : [Mosquitto won't start on boot after raspbian and emonsd update](https://community.openenergymonitor.org/t/mosquitto-wont-start-on-boot-after-raspian-and-emonsd-update/5588). It seems Mosquitto is restarted “too early” after creating the log file directory.

First, try to start mosquitto manually :  
`sudo service mosquitto start`

If it works, could you try to make a small change to `/home/pi/emonpi/rc.local_jessieminimal` (I recommend you do a backup of the file before…) ?

After line 22 (comment for service restart), add `sleep 11` (line 23).

```
 22 # Restart services,they should run happy now log dir's are created
 23 sleep 11
 24 service apache2 restart
 25 service redis-server restart
 26 service mosquitto restart
 27 service supervisor restart

```

Then, reboot !

Could you confirm it works (or not) ?

I am not sure it is the best / cleanest solution though…

JS

---

<div class="post-metadata">

**Author:** ![cormad](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/cormad/32/2335_2.png) [@cormad](https://community.openenergymonitor.org/u/cormad)\
**Post date:** [7 November 2017 22:48 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/9 "2017-11-07T22:48:16Z")

</div>

Hi JS,

You rock 🙂 . I can confirm that works !

Much Thanks

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [8 November 2017 15:43 UTC](https://community.openenergymonitor.org/t/mqtt-no-longer-working-after-update-from-emonsd-03may16-to-most-current-version/5578/10 "2017-11-08T15:43:49Z")

</div>

Thanks @jsroques 👍

I will temporary add this change to the rc.local script. This change will be automatically pulled in by all emonPi’s:

> <https://github.com/openenergymonitor/emonpi/commit/e59f9fdb7703cc186882af609a9816925bd990eb>
>
> https://community.openenergymonitor.org/t/mosquitto-wont-start-on-boot-after-ras…pian-and-emonsd-update/5588

let’s continue the discussion on the other thread how starting the services can be better engineered going forward:

> [@Mosquitto won't start on boot after raspbian and emonsd update](https://community.openenergymonitor.org/t/mosquitto-wont-start-on-boot-after-raspian-and-emonsd-update/5588/3):
>
> Hi @jsroques, Nice work tracking this issue down. I have been unable to replicate the issue. On system (stock [emonSD-26Oct17](https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log#emonsd-26oct17)) it does eventually start. sudo journalctl -u mosquitto -- Logs begin at Wed 2017-11-08 15:10:19 UTC, end at Wed 2017-11-08 15:11:23 UTC. -- Nov 08 15:10:21 emonpi systemd[1]: Starting Mosquitto MQTT Broker... Nov 08 15:10:21 emonpi systemd[1]: Started Mosquitto MQTT Broker. Nov 08 15:10:22 emonpi mosquitto[517]: 1510153822: Error: Unable to open log file /var/log/mosqui…
