Error during remote post: 500 Server Error: Internal Server Error for url

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
Post Reply
allvets
Posts: 6
Joined: Wed Nov 16, 2022 3:38 pm

Error during remote post: 500 Server Error: Internal Server Error for url

Post by allvets »

Need some assistance on this. I had mlapi working yesterday, however did a clean install to move all models off the ZM server and loaded all onto the mlapi. However, now when I start an event I receive the following error and obviously no detection is completed.

I was able to request the ACCESS_TOKEN and is posted when running:

Code: Select all

 sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini  --eventid 19 --monitorid 3 --debug
I get:
11/29/22 12:20:46 zmesdetect_m3[19424] INF ZMLog.py:292 [Setting up signal handler for logs]
11/29/22 12:20:46 zmesdetect_m3[19424] INF ZMLog.py:301 [Switching global logger to ZMLog]
11/29/22 12:20:47 zmesdetect_m3[19424] INF zm_detect.py:284 [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
, OpenCV:4.6.0|------------]
11/29/22 12:20:48 zmesdetect_m3[19424] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]
11/29/22 12:20:48 zmesdetect_m3[19424] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]
DBG2 [zmesdetect_m3] [Secret token found in config: !ZM_PORTAL]
DBG2 [zmesdetect_m3] [Secret token found in config: !ZM_USER]
DBG2 [zmesdetect_m3] [Secret token found in config: !ZM_PASSWORD]
DBG2 [zmesdetect_m3] [Secret token found in config: !ZM_API_PORTAL]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_USER]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_PASSWORD]
DBG1 [zmesdetect_m3] [allowing self-signed certs to work...]
DBG2 [zmesdetect_m3] [Now checking for monitor overrides]
DBG3 [zmesdetect_m3] [[monitor-3] overrides key:match_past_detections with value:no]
DBG3 [zmesdetect_m3] [[monitor-3] overrides key:wait with value:5]
DBG3 [zmesdetect_m3] [[monitor-3] overrides key:object_detection_pattern with value:(person)]
DBG3 [zmesdetect_m3] [[monitor-3] overrides key:import_zm_zones with value:yes]
DBG3 [zmesdetect_m3] [[monitor-3] overrides key:resize with value:no]
DBG2 [zmesdetect_m3] [my_model_sequence is not a polygon, adding it as unknown string key]
DBG2 [zmesdetect_m3] [import_zm_zones: match_reason=False and reason=None]
DBG2 [zmesdetect_m3] [Getting ZM zones using http://localhost/zm/api/zones/forMonito ... x&pass=yyy]
DBG2 [zmesdetect_m3] [importing zoneminder polygon: all [0,0 1023,0 1023,767 0,767]]
DBG3 [zmesdetect_m3] [Finally, doing parameter substitution]
11/29/22 12:20:48 zmesdetect_m3[19424] INF zm_detect.py:313 [Importing remote shim classes for Object/Face]
11/29/22 12:20:51 zmesdetect_m3[19424] INF zm_detect.py:334 [Connecting with ZM APIs]
DBG2 [zmesdetect_m3] [API SSL certificate check has been disbled]
DBG1 [zmesdetect_m3] [using username/password for login]
DBG2 [zmesdetect_m3] [Using new token API]
DBG1 [zmesdetect_m3] [Access token expires on:2022-11-29 14:20:51.673779 [7200s]]
DBG1 [zmesdetect_m3] [Refresh token expires on:2022-11-30 12:20:51.675513 [86400s]]
DBG2 [zmesdetect_m3] [using ml_sequence]
DBG2 [zmesdetect_m3] [using stream_sequence]
11/29/22 12:20:51 zmesdetect_m3[19424] INF zm_detect.py:48 [Detecting using remote API Gateway http://192.168.32.210:5000/api/v1]
DBG2 [zmesdetect_m3] [Found token file, checking if token has not expired]
DBG1 [zmesdetect_m3] [Access token is valid for 3485 more seconds]
DBG2 [zmesdetect_m3] [Invoking mlapi with url:http://192.168.32.210:5000/api/v1/detec ... ype=object and json: mid=3 reason=None stream=19, stream_options={'frame_strategy': 'most_models', 'frame_set': 'snapshot,alarm', 'contig_frames_before_error': 5, 'max_attempts': 3, 'sleep_between_attempts': 4, 'resize': 800, 'api': None, 'polygons': [{'name': 'all', 'value': [(0, 0), (1023, 0), (1023, 767), (0, 767)], 'pattern': None}]} ml_overrides={'model_sequence': 'object,face', 'object': {'pattern': '(person)'}, 'face': {'pattern': '.*'}, 'alpr': {'pattern': '.*'}} headers={'Authorization': 'Bearer ACCESS_TOKEN was here} params={'delete': True, 'response_format': 'zm_detect'} ]
11/29/22 12:20:51 zmesdetect_m3[19424] ERR zm_detect.py:160 [Error during remote post: 500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 158, in remote_detect
r.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect
]
11/29/22 12:20:51 zmesdetect_m3[19424] ERR zm_detect.py:405 [Error with remote mlapi:500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 401, in main_handler
matched_data,all_data = remote_detect(stream=stream, options=stream_options, api=zmapi, args=args)
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 158, in remote_detect
r.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect
]
11/29/22 12:20:51 zmesdetect_m3[19424] FAT zm_detect.py:561 [Unrecoverable error:'NoneType' object is not subscriptable Traceback:Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 556, in <module>
main_handler()
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 440, in main_handler
'labels': matched_data['labels'],
TypeError: 'NoneType' object is not subscriptable
]
This is from the log file zmesdetect_m3.log
11/29/22 11:10:42 zmesdetect_m3[17907] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]
11/29/22 11:10:42 zmesdetect_m3[17907] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]
11/29/22 11:10:43 zmesdetect_m3[17907] INF zm_detect.py:313 [Importing remote shim classes for Object/Face]
11/29/22 11:10:45 zmesdetect_m3[17907] INF zm_detect.py:334 [Connecting with ZM APIs]
11/29/22 11:10:46 zmesdetect_m3[17907] INF zm_detect.py:48 [Detecting using remote API Gateway http://192.168.32.210:5000/api/v1]
11/29/22 11:10:46 zmesdetect_m3[17907] ERR zm_detect.py:160 [Error during remote post: 500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect]
11/29/22 11:10:46 zmesdetect_m3[17907] ERR zm_detect.py:405 [Error with remote mlapi:500 Server Error: Internal Server Error for url: http://192.168.32.210:5000/api/v1/detec ... =zm_detect]
11/29/22 11:10:46 zmesdetect_m3[17907] FAT zm_detect.py:561 [Unrecoverable error:'NoneType' object is not subscriptable Traceback:Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 556, in <module>
main_handler()
File "/var/lib/zmeventnotification/bin/zm_detect.py", line 440, in main_handler
'labels': matched_data['labels'],
TypeError: 'NoneType' object is not subscriptable
]
This is my first time posting here, so I hope I've provided as much information as necessary. Any assistance would be greatly appreciated
Attachments
objectconfig.ini
(24.29 KiB) Downloaded 64 times
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Error during remote post: 500 Server Error: Internal Server Error for url

Post by Magic919 »

What about mlapi logs? Check those.
-
allvets
Posts: 6
Joined: Wed Nov 16, 2022 3:38 pm

Re: Error during remote post: 500 Server Error: Internal Server Error for url

Post by allvets »

Magic919 wrote: Tue Nov 29, 2022 7:34 pm What about mlapi logs? Check those.
In mlapi_error.log this keeps repeating:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 467, in wrapper
resp = resource(*args, **kwargs)
File "/usr/lib/python3/dist-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
resp = meth(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/flask_jwt_extended/view_decorators.py", line 108, in wrapper
return fn(*args, **kwargs)
File "/var/lib/mlapi/mlapi.py", line 132, in post
g.logger.Debug(2, 'Overriding global {} with {}...'.format(key, g.monitor_config[mid][key][:30]))
TypeError: 'int' object is not subscriptable
and in mlapi.log this is repeating:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 467, in wrapper
resp = resource(*args, **kwargs)
File "/usr/lib/python3/dist-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
resp = meth(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/flask_jwt_extended/view_decorators.py", line 108, in wrapper
return fn(*args, **kwargs)
File "/var/lib/mlapi/mlapi.py", line 132, in post
g.logger.Debug(2, 'Overriding global {} with {}...'.format(key, g.monitor_config[mid][key][:30]))
TypeError: 'int' object is not subscriptable
And when I run:

Code: Select all

sudo systemctl status mlapi
mlapi.service - Machine Learning API service
Loaded: loaded (/etc/systemd/system/mlapi.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-11-29 12:59:47 CST; 2h 7min ago
Process: 583 ExecStartPost=/bin/sh -c umask 022; pgrep mlapi.py > /var/run/mlapi.pid (code=exited, status=0/SUCCESS)
Main PID: 581 (mlapi.py)
Tasks: 1 (limit: 8986)
CPU: 10.984s
CGroup: /system.slice/mlapi.service
└─581 /usr/bin/python3 /var/lib/mlapi/mlapi.py -c ./mlapiconfig.ini

Nov 29 12:59:47 allvetsalpr systemd[1]: Starting Machine Learning API service...
Nov 29 12:59:47 allvetsalpr systemd[1]: Started Machine Learning API service.
Attachments
mlapiconfig.ini
(14.19 KiB) Downloaded 61 times
allvets
Posts: 6
Joined: Wed Nov 16, 2022 3:38 pm

Re: Error during remote post: 500 Server Error: Internal Server Error for url

Post by allvets »

When I run this from the zm server:

Code: Select all

curl -H "Content-Type:application/json" -H "Authorization: Bearer ${ACCESS_TOKEN}" -XPOST -d "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/c/c4/Anna%27s_hummingbird.jpg\"}" http://localhost:5000/api/v1/detect/object
After editing the mlapiconfig.ini to include 'bird' in the global detection list, I get the response back "bird'
Post Reply