HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
Post Reply
warpengine
Posts: 5
Joined: Wed Nov 23, 2022 9:48 am

HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by warpengine »

Hello,

I'm trying to set up EventNotification on my Fedora 34 server, everything looks fine but for this error on API:

Unrecoverable error:500 Server Error: Internal Server Error for url: https://********/zm/api/host/login.json Traceback:Traceback (most recent call last): File "/var/lib/zmeventnotification/bin/zm_detect.py", line 556, in main_handler() File "/var/lib/zmeventnotification/bin/zm_detect.py", line 335, in main_handler zmapi = zmapi.ZMApi(options=api_options) File "/usr/local/lib/python3.10/site-packages/pyzm/api.py", line 80, in __init__ self._login() File "/usr/local/lib/python3.10/site-packages/pyzm/api.py", line 233, in _login raise err File "/usr/local/lib/python3.10/site-packages/pyzm/api.py", line 203, in _login r.raise_for_status() File "/usr/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self)requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://***********/zm/api/host/login.json

The hooks are working but apparently the API on ZM are not working. I've checked and the checkbox is ticket for API on configuration and the .config files are ok as per the installation guide. I use Apache as webserver. Even if I run Curl I get HTTP500 on get version for API:

curl --verbose --insecure https://***************/zm/api/host/getVersion.json
* Trying ************:443...
* Connected to ************** (*************) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=--; ST=SomeState; L=SomeCity; O=SomeOrganization; OU=SomeOrganizationalUnit; CN=CAPSULE-SERVER; emailAddress=root@CAPSULE-SERVER
* start date: Nov 20 14:24:25 2022 GMT
* expire date: Nov 20 14:24:25 2023 GMT
* issuer: C=--; ST=SomeState; L=SomeCity; O=SomeOrganization; OU=SomeOrganizationalUnit; CN=CAPSULE-SERVER; emailAddress=root@CAPSULE-SERVER
* SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /zm/api/host/getVersion.json HTTP/1.1
> Host2:***********.
> User-Agent: curl/7.79.1
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 23 Nov 2022 09:58:18 GMT
< Server: Apache/2.4.54 (Fedora Linux) OpenSSL/1.1.1q mod_auth_gssapi/1.6.3 mod_wsgi/4.9.0 Python/3.10
< X-Powered-By: PHP/8.0.25
< Content-Length: 0
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
* Closing connection 0
* TLSv1.3 (IN), TLS alert, close notify (256):
* TLSv1.3 (OUT), TLS alert, close notify (256):

I've searched this forum and on Internet but I could not find any clue on recent versions of ZM (I'm using the latest).
Any help is welcome, thanks!
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by tsp84 »

Turn on debug logs for zm. It's a zm problem not zmeventnotification.

Debug logs will help narrow down what the issue could be.
warpengine
Posts: 5
Joined: Wed Nov 23, 2022 9:48 am

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by warpengine »

I've turn on debug logs and checked all logs but I cannot see anything more then the error I've already posted. There is no specific log file for the API, maybe I'm wrong but what would be the file to look into the logs for this kind of errors?
User avatar
iconnor
Posts: 2261
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by iconnor »

/var/log/apache2/error.log, /var/log/zm/cake_error.log /var/log/zm/web_php.log are all possible candidates.
warpengine
Posts: 5
Joined: Wed Nov 23, 2022 9:48 am

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by warpengine »

/var/log/apache2/error.log

[Wed Nov 23 10:10:06.404811 2022] [mpm_event:notice] [pid 1596:tid 1596] AH00492: caught SIGWINCH, shutting down gracefully
[Wed Nov 23 10:10:07.462536 2022] [suexec:notice] [pid 256046:tid 256046] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::d250:99ff:fe34:d133%enp2s0. Set the 'ServerName'>
[Wed Nov 23 10:10:07.472437 2022] [lbmethod_heartbeat:notice] [pid 256046:tid 256046] AH02282: No slotmem from mod_heartmonitor
[Wed Nov 23 10:10:07.475124 2022] [mpm_event:notice] [pid 256046:tid 256046] AH00489: Apache/2.4.54 (Fedora Linux) OpenSSL/1.1.1q mod_auth_gssapi/1>
[Wed Nov 23 10:10:07.475141 2022] [core:notice] [pid 256046:tid 256046] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

/var/log/zm/cake_error.log

I don't have "zm" dir, I've only "zoneminder" dir and there is no cake_error.log in there while web_php.log is available but have nothing interesting IMHO, anyway here is the excerpt:

(
[lifetime] => 3600
[path] => /
[domain] =>
[secure] =>
[httponly] => 1
[samesite] => Strict
)] at /usr/share/zoneminder/www/includes/session.php line 44
11/23/22, 1:45:13 PM UTC.927560 web_php[1588].DBG [192.168.5.160] [View: request Request: log Action: User: admin] at /usr/share/zoneminder/www/index.php line 212
11/23/22, 1:45:16 PM UTC.878919 web_php[250599].DBG [192.168.5.160] [Setting cookie parameters to Array
(
[lifetime] => 3600
[path] => /
[domain] =>
[secure] =>
[httponly] => 1
[samesite] => Strict
)] at /usr/share/zoneminder/www/includes/session.php line 44
11/23/22, 1:45:16 PM UTC.883484 web_php[250599].DBG [192.168.5.160] [View: options Request: Action: User: admin] at /usr/share/zoneminder/www/index.php line 212
11/23/22, 1:45:22 PM UTC.473697 web_php[1587].DBG [192.168.5.160] [Setting cookie parameters to Array
(
[lifetime] => 3600
[path] => /
[domain] =>
[secure] =>
[httponly] => 1
[samesite] => Strict
)] at /usr/share/zoneminder/www/includes/session.php line 44
11/23/22, 1:45:22 PM UTC.481157 web_php[1587].DBG [192.168.5.160] [View: options Request: Action: User: admin] at /usr/share/zoneminder/www/index.php line 212
11/23/22, 1:46:02 PM UTC.078853 web_php[144279].DBG [192.168.5.160] [Setting cookie parameters to Array
(
[lifetime] => 3600
[path] => /
[domain] =>
[secure] =>
[httponly] => 1
[samesite] => Strict
)] at /usr/share/zoneminder/www/includes/session.php line 44
11/23/22, 1:46:02 PM UTC.087029 web_php[144279].DBG [192.168.5.160] [View: options Request: Action: options User: admin] at /usr/share/zoneminder/www/index.php line 212
11/23/22, 1:46:02 PM UTC.093341 web_php[144279].DBG [192.168.5.160] [Redirecting to ?view=options&tab=logging] at /usr/share/zoneminder/www/index.php line 260
warpengine
Posts: 5
Joined: Wed Nov 23, 2022 9:48 am

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by warpengine »

I've found also this on /var/log/php-fpm/www-error.log

thrown in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php on line 91
[23-Nov-2022 13:53:06 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apc_fetch() in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php:91
Stack trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(363): ApcEngine->read()
#1 /usr/share/zoneminder/www/api/lib/Cake/I18n/I18n.php(235): Cache::read()
#2 /usr/share/zoneminder/www/api/lib/Cake/basics.php(636): I18n::translate()
#3 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(182): __d()
#4 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine()
#5 /usr/share/zoneminder/www/api/app/Config/core.php(375): Cache::config()
#6 /usr/share/zoneminder/www/api/lib/Cake/Core/Configure.php(72): include('/usr/share/zone...')
#7 /usr/share/zoneminder/www/api/lib/Cake/bootstrap.php(442): Configure::bootstrap()
#8 /usr/share/zoneminder/www/api/app/webroot/index.php(102): include('/usr/share/zone...')
#9 {main}
thrown in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php on line 91
[23-Nov-2022 13:53:36 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apc_fetch() in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php:91
Stack trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(363): ApcEngine->read()
#1 /usr/share/zoneminder/www/api/lib/Cake/I18n/I18n.php(235): Cache::read()
#2 /usr/share/zoneminder/www/api/lib/Cake/basics.php(636): I18n::translate()
#3 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(182): __d()
#4 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine()
#5 /usr/share/zoneminder/www/api/app/Config/core.php(375): Cache::config()
#6 /usr/share/zoneminder/www/api/lib/Cake/Core/Configure.php(72): include('/usr/share/zone...')
#7 /usr/share/zoneminder/www/api/lib/Cake/bootstrap.php(442): Configure::bootstrap()
#8 /usr/share/zoneminder/www/api/app/webroot/index.php(102): include('/usr/share/zone...')
#9 {main}
thrown in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/ApcEngine.php on line 91
warpengine
Posts: 5
Joined: Wed Nov 23, 2022 9:48 am

Re: HTTP 500 Error on API access from zm_detetc .../zm/api/host/login.json

Post by warpengine »

Ok I think I've resolved, the last PHP log made me thinking and I've found the missing package in PHP-APCU which was causing "Call to undefined function apc_fetch()". Installed the package resolved the HTTP500 error.

Thanks to all for your hints :D
Post Reply