MQTT Error

Support for the docker image maintained by dlandon
Post Reply
justgraduated2008
Posts: 2
Joined: Sun Sep 27, 2020 11:42 pm

MQTT Error

Post by justgraduated2008 » Mon Sep 28, 2020 12:00 am

I've been trying for several nights to get things up and running with Event Server. I have several monitors running in ZoneMinder but when I run zmeventnotification it exits after the first MQTT tick interval passes with the following error:

Expected 'PeerService' at /usr/local/share/perl/5.26.1/Net/MQTT/Simple.pm line 159.

Also what's interesting is it doesn't seem to respect the config file if I turn off MQTT in the config file. The only way I can get it to turn off is if I comment out the enable line and it takes the default of off... I've tried off, 0, false.

I would like to push the notifications out via MQTT but can't get past this. I know the MQTT server is working as I use it for several other projects ( eclipse-mosquitto:1.5.4) Here's what I've tried:

- Running from Master branch
- Running from Stable Branch
- DNS name for MQTT server(include port and don't include port)
- IP Address for MQTT Server (include port and don't include port)
- Reinstall MQTT Perl module
- downgrade MQTT Perl Module
- Reinstall socket module (seems like that's the interface it's unhappy with)
- Downgrade socket module

Here's the output:
root@ec86f8e977cd:/# sudo -u www-data zmeventnotification.pl
09/27/20 18:56:03.031970 zmeventnotification[8662].INF [main:888] [PARENT: using config file: /etc/zm/zmeventnotification.ini]
09/27/20 18:56:03.044115 zmeventnotification[8662].INF [main:888] [PARENT: using secrets file: /etc/zm/secrets.ini]
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: Got secret token !ZMES_PICTURE_URL
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: Got secret token !ZM_USER
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: Got secret token !ZM_PASSWORD

Configuration (read /etc/zm/zmeventnotification.ini):

Secrets file.......................... /etc/zm/secrets.ini
Base data path........................ /var/lib/zmeventnotification
Restart interval (secs)............... (undefined)

Use admin interface .................. no
Admin interface password.............. (undefined)
Admin interface persistence file ..... /var/lib/zmeventnotification/misc/escontrol_interface.dat

Port ................................. 9000
Event check interval ................. 5
Monitor reload interval .............. 300
Skipped monitors...................... (undefined)

Auth enabled ......................... yes
Auth timeout ......................... 20

Use API Push.......................... no
API Push Script....................... (undefined)

Use FCM .............................. yes
FCM Date Format....................... %I:%M %p, %d-%b
FCM API key .......................... (defined)
Token file ........................... /var/lib/zmeventnotification/push/tokens.txt

Use MQTT ............................. yes
MQTT Server .......................... mqtt.workingdomain.com
MQTT Topic ........................... zoneminder
MQTT Username ........................ (undefined)
MQTT Password ........................ (undefined)
MQTT Retain .......................... no
MQTT Tick Interval ................... 15

SSL enabled .......................... yes
SSL cert file ........................ /etc/apache2/ssl/zoneminder.crt
SSL key file ......................... /etc/apache2/ssl/zoneminder.key

Verbose .............................. yes
ES Debug level.........................2
Read alarm cause ..................... yes
Tag alarm event id ................... yes
Use custom notification sound ........ no
Send event end notification............no

Use Hooks............................. yes
Hook Script on Event Start ........... '/var/lib/zmeventnotification/bin/zm_event_start.sh'
User Script on Event Start.............(undefined)
Hook Script on Event End.............. '/var/lib/zmeventnotification/bin/zm_event_end.sh'
User Script on Event End.............(undefined)
Hook Skipped monitors................. (undefined)

Notify on Event Start (hook success).. all
Notify on Event Start (hook fail)..... none
Notify on Event End (hook success).... web,api
Notify on Event End (hook fail)....... none
Notify End only if Start success...... yes

Use Hook Description.................. yes
Keep frame match type................. yes
Store Frame in ZM......................yes

Picture URL .......................... https://zm.workingdomain.com/zm/index.p ... &width=600
Include picture....................... yes
Picture username ..................... ha
Picture password ..................... (defined)

CONSOLE INF:2020-09-27,18:56:03 PARENT: Push enabled via FCM
09/27/20 18:56:03.219799 zmeventnotification[8662].INF [main:888] [PARENT: Push enabled via FCM]
CONSOLE INF:2020-09-27,18:56:03 PARENT: MQTT Enabled
09/27/20 18:56:03.226896 zmeventnotification[8662].INF [main:888] [PARENT: MQTT Enabled]
CONSOLE INF:2020-09-27,18:56:03 PARENT: |------- Starting ES version: 5.15.6-Docker ---------|
09/27/20 18:56:03.229885 zmeventnotification[8662].INF [main:888] [PARENT: |------- Starting ES version: 5.15.6-Docker ---------|]
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: Started with: perl:/usr/bin/perl and command:/usr/bin/zmeventnotification.pl
Can't ignore signal CHLD, forcing to default.
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: ES invoked manually. Will handle restarts ourselves
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: Parent<--Child pipe ready
CONSOLE INF:2020-09-27,18:56:03 PARENT: Event Notification daemon v 5.15.6-Docker starting

09/27/20 18:56:03.503817 zmeventnotification[8662].INF [main:888] [PARENT: Event Notification daemon v 5.15.6-Docker starting]
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: Initializing FCM tokens...
CONSOLE INF:2020-09-27,18:56:03 PARENT: Initializing MQTT connection...
09/27/20 18:56:03.508822 zmeventnotification[8662].INF [main:888] [PARENT: Initializing MQTT connection...]
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: Intialized MQTT without auth
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: Total event client connections: 1

CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: -->checkNewEvents: Connection 1: ID-> IP->(none) Token->:... Plat: Push:
CONSOLE INF:2020-09-27,18:56:03 PARENT: Re-loading monitors
09/27/20 18:56:03.511480 zmeventnotification[8662].INF [main:888] [PARENT: Re-loading monitors]
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: Loading ManCave
CONSOLE DBG-1:2020-09-27,18:56:03 PARENT: ESCONTROL_INTERFACE is disabled. Not saving control data
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: checkEvents() new events found=0
CONSOLE DBG-2:2020-09-27,18:56:03 PARENT: About to start listening to socket
CONSOLE INF:2020-09-27,18:56:03 PARENT: Secure WS(WSS) is enabled...
09/27/20 18:56:03.523123 zmeventnotification[8662].INF [main:888] [PARENT: Secure WS(WSS) is enabled...]
CONSOLE INF:2020-09-27,18:56:03 PARENT: Web Socket Event Server listening on port 9000
09/27/20 18:56:03.525282 zmeventnotification[8662].INF [main:888] [PARENT: Web Socket Event Server listening on port 9000]
CONSOLE DBG-2:2020-09-27,18:56:08 PARENT: ---------->Tick START<--------------
CONSOLE DBG-2:2020-09-27,18:56:08 PARENT: There are 0 active child forks...
CONSOLE DBG-2:2020-09-27,18:56:08 PARENT: checkEvents() new events found=0
CONSOLE DBG-2:2020-09-27,18:56:08 PARENT: There are 0 new Events to process
CONSOLE DBG-2:2020-09-27,18:56:08 PARENT: ---------->Tick END<--------------
CONSOLE DBG-2:2020-09-27,18:56:13 PARENT: ---------->Tick START<--------------
CONSOLE DBG-2:2020-09-27,18:56:13 PARENT: There are 0 active child forks...
CONSOLE DBG-2:2020-09-27,18:56:13 PARENT: checkEvents() new events found=0
CONSOLE DBG-2:2020-09-27,18:56:13 PARENT: There are 0 new Events to process
CONSOLE DBG-2:2020-09-27,18:56:13 PARENT: ---------->Tick END<--------------
CONSOLE DBG-2:2020-09-27,18:56:18 PARENT: ---------->Tick START<--------------
CONSOLE DBG-2:2020-09-27,18:56:18 PARENT: MQTT tick interval (15 sec) elapsed.
Expected 'PeerService' at /usr/local/share/perl/5.26.1/Net/MQTT/Simple.pm line 159.
Any insights on how to get MQTT working?

BruceHowells
Posts: 1
Joined: Mon Sep 28, 2020 8:25 pm

Re: MQTT Error

Post by BruceHowells » Mon Sep 28, 2020 8:33 pm

Probably not what you want to hear, but I ran into this and found your post doing searches for a fix.

In my case, I'm running the mosquitto and zoneminder containers on the same host. When I specified the IP of the host itself, I got the error you describe; when I used 127.0.0.1, all was happy.

There's a lot of conflicting information about how to manage this kind of "hairpin" - much of it conflicting and platform specific.

For me, I'm going to go forward with running the mqtt container alongside my zm container, with vmeventnotifcation using 127.0.0.1 as the server, while (in my case) the Homebridge server on a different host will use the ip of the Docker host.

justgraduated2008
Posts: 2
Joined: Sun Sep 27, 2020 11:42 pm

Re: MQTT Error

Post by justgraduated2008 » Tue Sep 29, 2020 2:01 pm

@BruceHowells - what network mode is ZoneMinder running in? I got the MQTT connection to work when I switched to Managed and specified a service link... but half of my monitors stopped working in that mode.

I've tried running in host and bridge mode and specifying 127.0.0.1 and still didn't work. I've even spun up another MQTT server on separate host to eliminate the hairpin and still is unhappy.

What OS are you hosting the containers on? Docker version?

cjd24
Posts: 14
Joined: Thu Dec 09, 2021 4:15 pm

Re: MQTT Error

Post by cjd24 » Thu Dec 09, 2021 4:34 pm

I know this is an old thread but I'm having the same issue, all seems to be set up correctly but nothing is coming through on my mqtt listener.
Mqtt true - password, broker, name all set correctly.

even ran 'perl -MCPAN -e "install Net::MQTT::Simple"' to be sure.

Not sure what else to do now.

zm running in a proxmox container. broker on another container on the same host/node.

cjd24
Posts: 14
Joined: Thu Dec 09, 2021 4:15 pm

Re: MQTT Error

Post by cjd24 » Thu Dec 09, 2021 6:39 pm

Anything look wrong in my debug output?

Code: Select all

# sudo -u www-data /usr/bin/zmeventnotification.pl --debug
INF:2021-12-09,15:36:39 PARENT: using config file: /etc/zm/zmeventnotification.ini
12/09/21 15:36:39.793647 zmeventnotification[963].INF [main:985] [PARENT: using config file: /etc/zm/zmeventnotification.ini]
INF:2021-12-09,15:36:39 PARENT: using secrets file: /etc/zm/secrets.ini
12/09/21 15:36:39.806064 zmeventnotification[963].INF [main:985] [PARENT: using secrets file: /etc/zm/secrets.ini]
DBG-2:2021-12-09,15:36:39 PARENT: Got secret token !ZMES_PICTURE_URL
DBG-2:2021-12-09,15:36:39 PARENT: Got secret token !ZM_USER
DBG-2:2021-12-09,15:36:39 PARENT: Got secret token !ZM_PASSWORD
DBG-3:2021-12-09,15:36:39 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'
DBG-3:2021-12-09,15:36:39 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'

Configuration (read /etc/zm/zmeventnotification.ini):

Secrets file.......................... /etc/zm/secrets.ini
Base data path........................ /var/lib/zmeventnotification
Restart interval (secs)............... (undefined)

Use admin interface .................. yes
Admin interface password.............. (defined)
Admin interface persistence file ..... /var/lib/zmeventnotification/misc/escontrol_interface.dat

Port ................................. 9002
Event check interval ................. 5
Monitor reload interval .............. 300
Skipped monitors...................... (undefined)

Auth enabled ......................... yes
Auth timeout ......................... 20

Use API Push.......................... no
API Push Script....................... (undefined)

Use FCM .............................. yes
Use FCM V1 APIs....................... yes
FCM Date Format....................... %I:%M %p, %d-%b
Only show latest FCMv1 message........ no
Android FCM push priority............. default

Token file ........................... /var/lib/zmeventnotification/push/tokens.txt

Use MQTT ............................. yes
MQTT Server .......................... 192.168.1.163
MQTT Topic ........................... zoneminder
MQTT Username ........................ xxxxxxx
MQTT Password ........................ (defined)
MQTT Retain .......................... yes
MQTT Tick Interval ................... 15
MQTT TLS CA ........................ (undefined)
MQTT TLS Cert ........................ (undefined)
MQTT TLS Key ........................ (undefined)
MQTT TLS Insecure ........................ no

SSL enabled .......................... no
SSL cert file ........................ /etc/apache2/ssl/zoneminder.crt
SSL key file ......................... /etc/apache2/ssl/zoneminder.key

Verbose .............................. yes
ES Debug level.........................4
Read alarm cause ..................... yes
Tag alarm event id ................... yes
Use custom notification sound ........ no
Send event start notification..........yes
Send event end notification............no
Monitor rules JSON file................(undefined)

Use Hooks............................. no
Hook Script on Event Start ........... '/var/lib/zmeventnotification/bin/zm_event_start.sh'
User Script on Event Start.............(undefined)
Hook Script on Event End.............. '/var/lib/zmeventnotification/bin/zm_event_end.sh'
User Script on Event End.............(undefined)
Hook Skipped monitors................. (undefined)

Notify on Event Start (hook success).. all
Notify on Event Start (hook fail)..... none
Notify on Event End (hook success).... fcm,web,api
Notify on Event End (hook fail)....... none
Notify End only if Start success...... yes

Use Hook Description.................. yes
Keep frame match type................. yes
Store Frame in ZM......................yes

Picture URL .......................... https://192.168.1.245:443/zm/index.php?view=image&eid=EVENTID&fid=objdetect&width=600
https://192.168.1.245:443/zm/index.php?view=image&eid=EVENTID&fid=snapshot&width=600
Include picture....................... yes
Picture username ..................... xxxxx
Picture password ..................... (defined)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests