ZoneMinder / zmeventnotification

Machine Learning powered Secure Websocket & MQTT based ZoneMinder event notification server
412 stars 128 forks source link

zm_detect.py crashes with Unrecoverable error:Expecting value: line 1 column 1 (char 0) #380

Closed WizRd0 closed 3 years ago

WizRd0 commented 3 years ago

OS and Version

Description:    Ubuntu 20.04.2 LTS

Event Server version

6.1.18

Hooks version (if you are using Object Detection)

app:6.1.18, pyzm:0.3.43

Are you using MLAPI? (Y/N)

Yes on a Jetson Nano (Issue isn't getting that far and it has previously worked)

If you are using MLAPI, please mention the version

2.2.11

The version of ZoneMinder you are using:

zoneminder 1.35.23~20210402213943-focal

What is the nature of your issue On the server with zoneminder & zmeventnotification installed I run the command

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --eventid 2 --monitorid 2 --debug --eventpath "/var/cache/zoneminder/events/Left/2021-04-03/2/" --reason "Motion Second Car"

I do not expect zm_detect.py to have an unrecoverable error, alternatively at least an error message I can work with.

The issue happens every time that zmeventnotification triggers the object detection and logs to the zmesdetect_m*.log files.

Debug Logs (if applicable)

04/03/21 13:58:35 zmesdetect_m2[14184] INF ZMLog.py:225 [Setting up signal handler for logs]
04/03/21 13:58:35 zmesdetect_m2[14184] INF ZMLog.py:234 [Switching global logger to ZMLog]
04/03/21 13:58:35 zmesdetect_m2[14184] INF zm_detect.py:271 [---------| app:6.1.18, pyzm:0.3.43, ES:6.1.18 , OpenCV:4.5.1|------------]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG1 utils.py:410 [secret filename: /etc/zm/secrets.ini]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ZM_PORTAL]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ZM_USER]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ZM_PASSWORD]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ZM_API_PORTAL]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ML_USER]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !ML_PASSWORD]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:383 [Secret token found in config: !PLATEREC_ALPR_KEY]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG1 utils.py:445 [allowing self-signed certs to work...]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG4 utils.py:455 [Now checking for monitor overrides]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:174 [import_zm_zones: match_reason=True and reason=Motion Second Car]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:177 [Getting ZM zones using http://cameras.domain.com/zm/api/zones/forMonitor/2.json?username=xxx&password=yyy&user=xxx&pass=yyy]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:228 [importing zoneminder polygon: car [17,391 642,325 971,746 94,1074]]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG1 utils.py:225 [dropping OurHouse as zones in alarm cause is Motion Second Car]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG1 utils.py:225 [dropping Footpath as zones in alarm cause is Motion Second Car]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 utils.py:228 [importing zoneminder polygon: second_car [169,240 544,205 705,522 157,474]]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG4 utils.py:520 [Finally, doing parameter substitution]
04/03/21 13:58:35 zmesdetect_m2[14184] INF zm_detect.py:300 [Importing remote shim classes for Object/Face]
04/03/21 13:58:35 zmesdetect_m2[14184] INF zm_detect.py:319 [Connecting with ZM APIs]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG2 api.py:67 [API SSL certificate check has been disbled]
04/03/21 13:58:35 zmesdetect_m2[14184] DBG1 api.py:176 [using username/password for login]
04/03/21 13:58:36 zmesdetect_m2[14184] FAT zm_detect.py:542 [Unrecoverable error:Expecting value: line 1 column 1 (char 0) Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 537, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 320, in main_handler
    zmapi = zmapi.ZMApi(options=api_options)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/api.py", line 75, in __init__
    self._login()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/api.py", line 200, in _login
    rj = r.json()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
]

Thanks!

pliablepixels commented 3 years ago

I do not expect zm_detect.py to have an unrecoverable error, alternatively at least an error message I can work with.

That depends on how bad the error is. Check your config values - looks like bad data

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
WizRd0 commented 3 years ago

ok so it was me being stupid, fix one break another 2 things :) Appreciate the pointer after being stuck for way to long trying to diag it, I had left the ZMES_PICTURE_URL as http:// instead of https:// once I changed this in secrets.ini it worked.

pliablepixels commented 3 years ago

Glad you got it resolved, but http:// instead of https:// should not be causing a json decode error. A json decode error happens when parsing fails. In this this case, parsing would succeed, but access would fail.