zm event notification server problem

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
Post Reply
timf
Posts: 132
Joined: Mon Mar 21, 2005 4:07 pm
Location: Lytham St.Annes Lancs.

zm event notification server problem

Post by timf »

Hi guys.

I've posted this question in the 1.34 section then the 1.36 section when I upgraded but no responses so I'm hoping someone here can help.

I had the same problem with both 1.34 and 1.36

Here's the problem

When starting ES manually in debug I get this fatal error

INF:2021-06-01,16:06:30 PARENT: using secrets file: /etc/zm/secrets.ini
01/06/21 16:06:30.468476 zmeventnotification[27276].INF [main:1022] [PARENT: using secrets file: /etc/zm/secrets.ini]
01/06/21 16:06:30.470918 zmeventnotification[27276].FAT [main:498] [Token:ES_CERT_FILE
/etc/letsencrypt/live/PORTAL/fullchain.pem not found in secret file]
DBG-:2021-06-01,16:06:30 PARENT: Received request to shutdown, please wait

I've edited secrets.ini as per below and tried changing ownerships etc all to no avail

ZM_PORTAL=https://PORTAL/zm
ZM_API_PORTAL=https://PORTAL/zm/api
ES_CERT_FILE=/etc/letsencrypt/live/PORTAL/fullchain.pem
ES_KEY_FILE=/etc/letsencrypt/live/PORTAL/privkey.pem

So it seems as though it's there but just not seen due to some config error ?

Any help gratefully received

Regards Tim
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm event notification server problem

Post by asker »

1. Does /etc/letsencrypt/live/PORTAL/fullchain.pem exist?
2. If it does exist, does

Code: Select all

sudo -u www-data ls -l /etc/letsencrypt/live/PORTAL/fullchain.pem 
work? (replace www-data with your web user)
3. What is the exact command you used to start the ES manually and does it work in daemon mode? (i.e. when run by ZM)
4. If all else fails google "letsencrypt fullchain.pem not found" --> there are many reasons and are mostly always related to permissions (there are many suggestions in letsencrypt forums)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
timf
Posts: 132
Joined: Mon Mar 21, 2005 4:07 pm
Location: Lytham St.Annes Lancs.

Re: zm event notification server problem

Post by timf »

Thanks for the reply,

as usual I think I've got it working shortly after making the above post. I found instructions on reddit on how to get ZMES running without HTTPS certs from letsencrypt, once that got ZMES running I was then able to run certbot afterwards to modify apache in true HTTPS mode.

I had tried changing the permissions for letsencrypt as you suggested but no joy.

Just need to check a few more things to make sure everything is playing nicely - so not out of the woods just yet....

Regards Tim
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm event notification server problem

Post by asker »

Sounds good, if it works, please post details on what you did to make things work so I can add it to the FAQ
If it doesn't work, please go back to my questions and answer them precisely (questions 1-3).
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
timf
Posts: 132
Joined: Mon Mar 21, 2005 4:07 pm
Location: Lytham St.Annes Lancs.

Re: zm event notification server problem

Post by timf »

Hi again,

to answer your questions and ask a few more I'm afraid.

As background here's where I'm at.

I followed this guide [urlhttps://www.reddit.com/r/ZoneMinder/comments/gv ... _with_gpu/][/url] exactly including the cuda section apart from installing ZM where I used this guide [urlhttps://bkjaya.wordpress.com/2021/05/15/how-to-install-zoneminder-1-36-0-focal1-on-ubuntu-20-04-lts-focal-fossa/][/url] for V1.36.

It all seemed to go ok with no errors.

As part of the install I initially used self signed certifs as per this secrets.ini as explained in the reddit guide

ZMES_PICTURE_URL=https://localhost/zm/index.php?view=ima ... &width=600 //changed localhost to my FQDN
ZM_USER=user // changed to match ZM users
ZM_PASSWORD=password // changed to match ZM users
ZM_PORTAL=https://localhost/zm // localhost changed to FQDN
ZM_API_PORTAL=https://localhost/zm/api // localhost changed to FQDN
ES_CERT_FILE=/etc/zm/apache2/ssl/zoneminder.crt // certs created locally with FQDN
ES_KEY_FILE=/etc/zm/apache2/ssl/zoneminder.key

Answer to question 1 yes - but only being used by Apache
Answer to question 2 - tried that no joy
Answer to question 3 - ZM appeared to work fine and send events in non HTTPS mode and after running sudo -u www-data zmeventnotification.pl --config /etc/zm/zmeventnotification.ini
Answer to question 4 - done that and tried all that I found with no joy. I suspect the root cause is my confusion about signed and unsigned certs plus where they are located.

With regard to #3 above the ES seemed to run without errors and responded to alarms.

I then ran certbot to generate real certifs and ZM was then working nicely in full HTTPS mode along with ES.

Questions

1. Is it ok to use self signed certs located at /etc/zm/apache2/ssl/ and letsencrypt certs for Apache located at etc/letsencrypt/live/fqdn ? Everything seems to work ok aprt from push notifications.

2. In the secrets.ini I get confused by what is meant by PORTAL - is this the external FQDN or the internal IP address of the server ? I actually run a fixed WAN IP address tied to a FQDN and port forward 443 to the server.

3. In the ZMnija app I have wss set to my FQDN:9000, but I don't get any push notifcations and my tokens.txt file only shows monitor 1 despite having 3 montiors running.

As you can hopefully see I've made some progress but not quite there yet - hopefuly answering the above questions will get me over the line !

Many thanks again Tim
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm event notification server problem

Post by asker »

Answer to question 2 - tried that no joy
Then you need to solve that problem. If you can't access it using your web user acct. then it won't work. chown it

2. In the secrets.ini I get confused by what is meant by PORTAL - is this the external FQDN or the internal IP address of the server ? I actually run a fixed WAN IP address tied to a FQDN and port forward 443 to the server.
Depends. If you need to access it from outside, the WAN FQDN. IF not, internal IP. To get picture notifications, need to be WAN. Like https://myserver.mydomain.com:port/zm
3. In the ZMnija app I have wss set to my FQDN:9000, but I don't get any push notifcations and my tokens.txt file only shows monitor 1 despite having 3 montiors running.
Dive into zmES debug logs and see what is happening. Can't guess for you.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
timf
Posts: 132
Joined: Mon Mar 21, 2005 4:07 pm
Location: Lytham St.Annes Lancs.

Re: zm event notification server problem

Post by timf »

hi again,

some progress !

fixed number 2 (entered the wrong user before doh !) entering sudo chown -R www-data:root /etc/letsencrypt/ results in ZMES running using just letsencrypt certs and when I update monitors (add monitor 3) on ZMnija ES the token on the PC gets changed ok

"token":"fk7-j28Q1EV-rufzQ3wwQz:APA91bFfg3I4XpJe7HuWHv_NDpQrROKC_4jV9GWDJy8JLO4HfWJ27DMaUT1i0KYBaQ8f7LScaTpG7m56RCl79ixEUytbWaRwY_9BVxzbsj3eM5mei6vc3ORPcvsk7qpNwxdj5ylpQ912"}
DBG-2:2021-06-05,18:58:32 PARENT: JOB: new token matched existing token: (dj5ylpQ912 <==> dj5ylpQ912) but connection did not (::ffff:82.132.187.242:50849 <==> ::ffff:82.132.187.242:50848)
DBG-1:2021-06-05,18:58:32 PARENT: JOB: Duplicate token found: marking ...dj5ylpQ912 to be deleted
DBG-2:2021-06-05,18:58:32 PARENT: JOB: token matched, updating entry in active connections
DBG-1:2021-06-05,18:58:32 PARENT: JOB: Storing token ...dj5ylpQ912,monlist:1,3,intlist:0,0,pushstate:enabled

DBG-2:2021-06-05,18:58:32 PARENT: SaveTokens called with:monlist=1,3, intlist=0,0, platform=ios, push=enabled
DBG-2:2021-06-05,18:58:32 PARENT: ---------->onConnect msg END<--------------

So far so good, but when I trigger an alarm on monitor 3 I get this (see below) - start hook processing failed , maybe a rules issue ?

Anymore suggestions ?

Regards Tim


min)<--------------
DBG-2:2021-06-05,19:00:13 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-06-05,19:00:13 PARENT: There are 1 active child forks & 0 zm_detect processes running...
DBG-2:2021-06-05,19:00:13 PARENT: checkEvents() new events found=0
DBG-2:2021-06-05,19:00:13 PARENT: There are 0 new Events to process
DBG-2:2021-06-05,19:00:13 PARENT: ---------->Tick END (active forks:1, total forks:3, active hooks: 0)<--------------
INF:2021-06-05,19:00:14 |----> FORK:shack (3), eid:250 end hooks/use hooks not being used, going to directly send out a notification if checks pass
05/06/21 19:00:14.269776 zmeventnotification[3357].INF [main:1022] [|----> FORK:shack (3), eid:250 end hooks/use hooks not being used, going to directly send out a notification if checks pass]
DBG-2:2021-06-05,19:00:16 |----> FORK:shack (3), eid:250 rules: Checking rules for alarm caused by eid:250, monitor:3, at: Sat Jun 5 19:00:16 2021 with cause:Motion All
DBG-1:2021-06-05,19:00:16 |----> FORK:shack (3), eid:250 rules: No rules found for Monitor, allowing:3
INF:2021-06-05,19:00:16 |----> FORK:shack (3), eid:250 Not sending event end alarm, as we did not send a start alarm for this, or start hook processing failed
05/06/21 19:00:16.270420 zmeventnotification[3357].INF [main:1022] [|----> FORK:shack (3), eid:250 Not sending event end alarm, as we did not send a start alarm for this, or start hook processing failed]
DBG-2:2021-06-05,19:00:18 PARENT: ----------> Tick START (active forks:1, total forks:3, active hooks: 0 running for:13 min)<--------------
DBG-2:2021-06-05,19:00:18 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-06-05,19:00:18 PARENT: There are 1 active child forks & 0 zm_detect processes running...
DBG-2:2021-06-05,19:00:18 PARENT: checkEvents() new events found=0
DBG-2:2021-06-05,19:00:18 PARENT: There are 0 new Events to process
DBG-2:2021-06-05,19:00:18 PARENT: ---------->Tick END (active forks:1, total forks:3, active hooks: 0)<--------------
DBG-1:2021-06-05,19:00:20 |----> FORK:shack (3), eid:2
timf
Posts: 132
Joined: Mon Mar 21, 2005 4:07 pm
Location: Lytham St.Annes Lancs.

Re: zm event notification server problem

Post by timf »

EDIT

I re-installed pip3 and that did the trick ZMES is now sending me notifications along with pictures saying I'm 98% human !

One other error reports its not using cuda most likely due to an install problem.

Thanks again for the nudges in the right direction and your patience !

Regards Tim

//////////////////////////////////
old message

found this in the ES log - looks like module cv2 is missing, will dig a bit deeper but strange as no errors during install.

Regards Tim

DBG-1:2021-06-05,19:35:38 |----> FORK:shack (3), eid:275 Invoking hook on event start:'/var/lib/zmeventnotification/bin/zm_event_start.sh' 275 3 "shack" "Motion New" "/var/cache/zoneminder/events/3/2021-06-05/275"
Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 15, in <module>
import imutils
File "/usr/local/lib/python3.8/dist-packages/imutils/__init__.py", line 8, in <module>
from .convenience import translate
File "/usr/local/lib/python3.8/dist-packages/imutils/convenience.py", line 6, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
Post Reply