[SOLVED] How to debug API DB connection issue?

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
SkippyDo
Posts: 227
Joined: Mon Nov 20, 2017 6:49 pm

[SOLVED] How to debug API DB connection issue?

Post by SkippyDo »

NOTE: This supersedes another recent thread I had: "API not working after upgrade from 1.36.12 to 1.36.18" - viewtopic.php?t=31826.

I recently upgraded from 1.36.12 (which had been working well for many months) to 1.36.18/19 and have lost the ability to connect to the [ZM] database via the API (I rely on this for zmNinja). I also performed some updates to the OS (Debian Bullseye), in which case I cannot rule this out as being the source of my issues. Anyway, I'm getting (using/testing via 'curl') a pretty generic error of:

"SQLSTATE[HY000] [2006] MySQL server has gone away"

ZM web interface works fine: MySQL server IS up and running. API calls for things like "getVersion" (not requiring a connection to the/a database?) works.

Getting these messages in mysql/error.log file:
[Warning] Aborted connection 13530 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Last edited by SkippyDo on Sun Jun 26, 2022 4:11 pm, edited 1 time in total.
SkippyDo
Posts: 227
Joined: Mon Nov 20, 2017 6:49 pm

[SOLVED] How to debug API DB connection issue?

Post by SkippyDo »

Not an answer to "how to debug," but figured out what was causing my problem. Commented out the following lines from www/api/app/Config/database.php:

'ssl_ca' => ZM_DB_SSL_CA_CERT,
'ssl_key' => ZM_DB_SSL_CLIENT_KEY,
'ssl_cert' => ZM_DB_SSL_CLIENT_CERT,

Unsure why this suddenly became an issue when upgrading from 1.36.12 to 1.36.18/19. Looking at the repository sources this file hasn't changed in a long time. I've got ZM_DB_SSL_CLIENT_KEY AND ZM_DB_SSL_CLIENT_KEY defined in my local/site-specific zm/conf.d/"custom.conf" file. NOTE: I cannot, however, enable to ZM_DB_SSL_CA_CERT variable as this tends to cause errors. ALL cert files are readable by the user www-data.
Post Reply