How to verify the API's

Forum for questions and support relating to the 1.28.x releases only.
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

How to verify the API's

Post by BiloxiGeek »

Just updated my SciLinux 7.1 system to zm 1.28.107-1 using the repo. I see all the API files under /usr/share/zoneminder/www/api/ but so far I can't seem to verify if it's all running correctly. I can see the web interface and all my cameras, zm itself seems to work just fine so far.

Rebooted after all that just to make sure and still get the output below when I try to bring up https://hostname/zm/api/host/getVersion.json and I get this:

Code: Select all

{
    "success": false,
    "data": {
        "code": 500,
        "name": "Database connection "Mysql" is missing, or could not be created.",
        "message": "SQLSTATE[28000] [1045] Access denied for user 'zmuser'@'localhost' (using password: YES)",
        "url": "\/zm\/api\/host\/getVersion.json",
        "exception": {
            "class": "MissingConnectionException",
            "code": 500,
            "message": "Database connection \"Mysql\" is missing, or could not be created.",
            "trace": [
                "#0 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Datasource\/DboSource.php(260): Mysql->connect()",
                "#1 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/ConnectionManager.php(105): DboSource->__construct(Array)",
                "#2 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Model.php(3479): ConnectionManager::getDataSource('default')",
                "#3 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Model.php(1128): Model->setDataSource('default')",
                "#4 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Model.php(3501): Model->setSource('Config')",
                "#5 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Model.php(2905): Model->getDataSource()",
                "#6 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Model\/Model.php(2877): Model->_readDataSource('first', Array)",
                "#7 \/usr\/share\/zoneminder\/www\/api\/app\/Controller\/AppController.php(62): Model->find('first', Array)",
                "#8 [internal function]: AppController->beforeFilter(Object(CakeEvent))",
                "#9 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Event\/CakeEventManager.php(244): call_user_func(Array, Object(CakeEvent))",
                "#10 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Controller\/Controller.php(674): CakeEventManager->dispatch(Object(CakeEvent))",
                "#11 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Routing\/Dispatcher.php(187): Controller->startupProcess()",
                "#12 \/usr\/share\/zoneminder\/www\/api\/lib\/Cake\/Routing\/Dispatcher.php(165): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))",
                "#13 \/usr\/share\/zoneminder\/www\/api\/app\/webroot\/index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))",
                "#14 {main}"
            ]
        },
        "queryLog": [

        ]
    }
}
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: How to verify the API's

Post by asker »

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
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

I did not, just tweaked my repo settings and updated the zoneminder package from the testing repo. As I understand things knnniggett did all the work to get the API's working within the rpm's.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: How to verify the API's

Post by asker »

It looks like the Database connection was not correctly updated in your case (The APIs need to be able to connect to the ZM DB). I can get you to fix it manually but I'd rather not - since it should be all handled within the repo like you suggested.

Let's wait for knnniggett to respond.
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
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

Maybe I'll drop a shrubbery in here to lure him in. :)
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How to verify the API's

Post by knight-of-ni »

He is using the rpm's in zmrepo. It worked in my test environment right out of the box.
[1045] Access denied for user 'zmuser'@'localhost' (using password: YES)
Says it can't connect to your database using the account zmuser@localhost.

Did you change the password for your zmuser to something other than the default?
Did you change the user account zoneminder uses to something other than "zmuser"?
Is mysql running on the local server?
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

Yes I changed password and checked /etc/zm/zm.conf and it's correct for the password.

mariadb.x86_64 is installed and running on the local server.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How to verify the API's

Post by knight-of-ni »

What I'm wondering if we have tested the API with a non-default password. It should work.
@asker Have you tried the API when the zmuser password has been changed to something unique?
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

FYI: The goal here is get the API working. And then give zmNinja a test drive on my desktops, iPhone and iPad.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How to verify the API's

Post by knight-of-ni »

Agreed. Asker has been the driving force behind API development. If there is a problem with the API, he is most qualified to speak to that.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: How to verify the API's

Post by asker »

Yes, I use non-standard passwords.
If you changed the password _after_ installing Zoneminder, then the API won't know about it.

Go to zoneminder/www/api/app/Config
Edit database.php

There is a class there called DATABASE_CONFIG - change the $default array to reflect your new details. Example

Code: Select all

public $default = array(
                'datasource' => 'Database/Mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'mynewDBusername',
                'password' => 'mynewDBpassword',
                'database' => 'zm',
                'prefix' => '',
                //'encoding' => 'utf8',
        );
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
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How to verify the API's

Post by knight-of-ni »

Ah, that is good to know. @BiloxiGeek I'd check your database.php. The error message you received would be a symptom of a misconfigured database.php.

Maybe in the future we can get the API to parse the variables it needs right out of the zm.conf file.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

Getting a different error now. Looks like the permissions and/or ownership of /usr/share/zoneminder/... is borked up. Should that whole file structure be owned apache:apache?

Code: Select all

Warning: mkdir(): Permission denied in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/FileEngine.php on line 379

Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php on line 323

Warning: /usr/share/zoneminder/www/api/app/tmp/cache/persistent/ is not writable in /usr/share/zoneminder/www/api/lib/Cake/Cache/Engine/FileEngine.php on line 384

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php:181 Stack trace: #0 /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_') #1 /usr/share/zoneminder/www/api/app/Config/core.php(376): Cache::config('_cake_core_', Array) #2 /usr/share/zoneminder/www/api/lib/Cake/Core/Configure.php(72): include('/usr/share/zone...') #3 /usr/share/zoneminder/www/api/lib/Cake/bootstrap.php(175): Configure::bootstrap(true) #4 /usr/share/zoneminder/www/api/app/webroot/index.php(90): include('/usr/share/zone...') #5 {main} thrown in /usr/share/zoneminder/www/api/lib/Cake/Cache/Cache.php on line 181
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How to verify the API's

Post by knight-of-ni »

Verify this folder is a symlink pointing to /var/lib/zoneminder/temp:
/usr/share/zoneminder/www/api/app/tmp

/var/lib/zoneminder/temp of course should be owned by apache.

The rpm package should have done all this for you.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: How to verify the API's

Post by BiloxiGeek »

That was the trick! The softlink is there and correct, but I've done a little jiggery-pokery on my setup. All the zoneminder stuff is actually on a big logical volume /export/zoneminder, and I've softlinked to that. The temp subdirectory was owned by root, but it's fixed now:

Code: Select all

{
    "version": "1.28.107",
    "apiversion": "1.28.107.1"
}
Now I can start fiddling with the desktop app.
Locked