Broke my APIs on Upgrade

Forum for questions and support relating to the 1.32.x releases only.
databoy2k
Posts: 28
Joined: Thu Nov 16, 2017 5:20 pm

Re: Broke my APIs on Upgrade

Post by databoy2k »

Yes; removing the /zm part of the link worked.
Nocifer
Posts: 37
Joined: Mon Oct 01, 2018 4:05 pm

Re: Broke my APIs on Upgrade

Post by Nocifer »

Sorry for the very late reply.

That worked, but you still get the wrong link in the monitor view, right? Well, getting the image when /zm is removed from the link means we can be sure that Nginx correctly points /cgi-bin to your CGI folder, and also that Nginx does not erroneously rewrite /cgi-bin to /zm/cgi-bin by itself. So this seems like a case of ZM's Web UI creating wrong links for some weird reason, which is probably a bug or a misconfiguration.

Alright, I traced the link creation to this part of the page:

Code: Select all

<div id="imageFeed"><img id="liveStream1" src="http://localhost/cgi-bin/nph-zms?etc..."/></div>
Which in the unprocessed PHP source code (skins/classic/views/watch.php, line 81) looks like this:

Code: Select all

<div id="imageFeed"><?php echo getStreamHTML( $monitor, array('scale'=>$scale) ); ?></div>
Which points us to includes/functions.php, line 2156:

Code: Select all

function getStreamHTML( $monitor, $options = array() ) {

...

}
And in particular to line 2198 within that code block:

Code: Select all

return getVideoStreamHTML( 'liveStream'.$monitor->Id(), $streamSrc, $options['width'], $options['height'], ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
Which leads us back to line 2191, where $streamSrc is processed and initialized:

Code: Select all

$streamSrc = $monitor->getStreamSrc( array(
Which finally gets us to lines 64 & 65:

Code: Select all

function getStreamSrc( $args, $querySep='&amp;' ) {
  $streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;
So, in your case, either ZM_BASE_URL or ZM_PATH_ZMS is set to the wrong value. My guess would be the latter, so check /etc/zoneminder/conf.d/01-system-paths.conf and make sure ZM_PATH_ZMS is set to /cgi-bin/nph-zms and not /zm/cgi-bin/zph-zms. Also, since this was an upgrade from 1.30.4, make sure you don't have any ZM_PATH_ZMS variable declared inside /etc/zoneminder/zm.conf (it used to be in previous versions that all ZM variables were declared in that file, so if you've kept your old version around, it could be overriding the new default value created during setup inside conf.d/01-system-paths.conf).
Last edited by Nocifer on Fri Oct 26, 2018 10:03 pm, edited 1 time in total.
databoy2k
Posts: 28
Joined: Thu Nov 16, 2017 5:20 pm

Re: Broke my APIs on Upgrade

Post by databoy2k »

I really appreciate you covering the logic as well. Most of the language is still quite cryptic to me (i'm working on JS for the purpose of Google Apps Scripts - that's a huge upgrade from my previous best knowledge of VBA... ... ...) but I follow the logic.

/etc/zm/conf.d/01-system-paths.conf did have the offending /zm/cgi-bin reference. Removing the /zm fixed the whole problem. /etc/zm/zm.conf did not have any offending entry.

I don't recall 01-system-paths.conf in the previous version. If it's new then I'm not sure where or how it gained that reference. Obviously updating the documentation is necessarily low priority, but we need to get the wiki and the docs updated to point new users to that file. It's essentially what is already pointed out there, but without the "paths" entry in the options we need to orient people to the right spot.

Thanks again for your help. I think that's all of my issues. I can now see all of the cameras from the web console. You're a champ.
Nocifer
Posts: 37
Joined: Mon Oct 01, 2018 4:05 pm

Re: Broke my APIs on Upgrade

Post by Nocifer »

Hmm. This is weird. The default path is supposed to be /cgi-bin/nph-zms, as is evident both by the official apache.conf and also by this part of CMakeLists.txt:

Code: Select all

set(ZM_PATH_ZMS "/cgi-bin/nph-zms" CACHE PATH
    "Web url to zms streaming server, default: /cgi-bin/nph-zms")
This means that for some reason, the wrong path was set when you installed ZM. As to why and how... I really can't think of anything right now.

But anyway, yes, that 01-system-paths.conf file is new in 1.32. It's mentioned in the changelog on the GitHub release page:

Code: Select all

    ...
    Options-> Paths moved into config files under conf.d folder
    ...
And inside zm.conf as well:

Code: Select all

# *** DO NOT EDIT THIS FILE ***
#
# To make custom changes to the variables below, create a new configuration
# file, with an extention of .conf, under the /etc/zoneminder/conf.d
# folder, containing your desired modifications.
It's also mentioned in various other files scattered in the source tree (e.g. in INSTALL) but I only know about it because I built a package for Arch Linux, so I had to skim over any and all files that seemed even remotely important in order to understand how to best build and deploy that package.

I'm not saying all this to bash you for not knowing about the change, I'm doing it because it goes to show that ZM's documentation is currently in somewhat of a complete mess, containing many contradictions and missing crucial pieces of info between its multiple incarnations in the Wiki, the ReadTheDocs site and even the repo files themselves.

I'm also not saying this to bash ZM or its developers, in fact it's the opposite: I aim (or rather hope), time permitting and ZM developers willing, to try and overhaul the documentation at some point in the near(-ish) future. But before I do that I need to have a better understanding of ZM, so I'm currently trying to familiarize myself with the project, determine best practices and/or the developers' preferences on various details (e.g. default paths, default files, default settings), etc.

So... yeah. Let's hope that in the future, requests for help with issues like this will be easier to kindly dismiss with a simple, heartwarming "RTFM" :mrgreen:
databoy2k
Posts: 28
Joined: Thu Nov 16, 2017 5:20 pm

Re: Broke my APIs on Upgrade

Post by databoy2k »

RTFM indeed; remember, us debian people think everything revolves around "sudo apt install". No compiling when we have PPAs (I say as I type this on a Win10 box).

Growing pains - ZM desperately needed an overhaul (my system also runs Shinobi, although I haven't had as much luck getting that set up) and the latest update to HomeAssistant just significantly upgraded ZM interaction to use run states so between that and 1.32 I'm feeling somewhat updated. Now if we could just figure out the documentation life would be good.

I try to avoid doing the docs myself because of how noob I am, but hopefully others have followed this thread and can both a) update the docs and b) piece together what we've fixed for their own systems.
terdinglage
Posts: 11
Joined: Thu Jan 03, 2019 7:14 am

Re: Broke my APIs on Upgrade

Post by terdinglage »

databoy2k wrote: Sat Oct 27, 2018 3:20 am RTFM indeed; remember, us debian people think everything revolves around "sudo apt install". No compiling when we have PPAs (I say as I type this on a Win10 box).

Growing pains - ZM desperately needed an overhaul (my system also runs yahoo, although I haven't had as much luck getting that set up) and the latest update to HomeAssistant just significantly upgraded ZM interaction to use run states so between that and 1.32 I'm feeling somewhat updated. Now if we could just figure out the documentation life would be good.

I try to avoid doing the docs myself because of how noob I am, but hopefully others have followed this thread and can both a) update the docs and b) piece together what we've fixed for their own systems.
I just tried to read through and follow all of this, and was I failed. Is there any chance you could paste the contents of your zoneminder.conf file that finally got everything working with the LEMP install method?
Post Reply