Another API issue..

Discussion topics related to mobile applications for ZoneMinder
SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Another API issue..

Post by SkippyDo » Sat May 16, 2020 11:48 am

zmNinja 1.4.005 on Android 7
Zoneminder 1.34.11 (new install)

Issue/error: "No monitors to display" Please check your credentials

As far as I can tell I'm getting authenticated, getting tokens: zmNinja says that I'm authenticated. I have SSL certs from Let's Encrypt: with my previous install of ZM (1.30.4) I was using self-signed certs and zmNinja worked fine.

zmNinja logs show error as being:

AM DEBUG*** Inside native HTTP error for url: {"status":500,"url":"https://<my server>/zm/api/monitors/index/Type%20!=WebSite.json?&token=<removed>

And from Firefox on my desktop as well as from my Android in which I am logged in to the ZM console, https://<my server>/zm/apimonitors.json returns:

{"name":"An Internal Error Has Occurred.","message":"An Internal Error Has Occurred.","url":"\/zm\/api\/monitors.json"}

And from Firefox on my desktop as well as from my Android in which I am logged in to the ZM console, https://<my server>/zm/api/host/getVersion.json returns:

{"success":false,"data":{"name":"Not Authenticated","message":"Not Authenticated","url":"\/zm\/api\/host\/getVersion.json","exception":{"class":"UnauthorizedException","code":401,"message":"Not Authenticated"}}}

BUT, if I enable OPT_USE_LEGACY_API_AUTH in Zoneminder I am able to get getVersion.json to return valid results (version and apiversion were returned). But monitors.json still fails with same error as above.

I've followed the instructions in https://zmninja.readthedocs.io/en/lates ... s/FAQ.html and https://zmninja.readthedocs.io/en/lates ... g-api.html.

I've deleted zmNinja (w/Cloud Sync disabled) and reinstalled (got me the latest 1.4005 version, from 1.3.086). No change.

Most likely a Zoneminder issue but my posting of this issue there isn't getting me anything.

User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Re: Another API issue..

Post by asker » Sat May 16, 2020 12:36 pm

As you've state, this is likely API issue not zmNinja. However, make sure you've tried clearing zmNinja API cache/exit app and try again.

If you can't get monitors.json to work on your desktop browser, try increasing debug level in CakePhp to see if it produces any useful output. Also monitor web_php logs (enable Debug logs)

To increase debug level of CakePHP, edit /usr/share/zoneminder/www/api/app/Config/core.php and the line where it says:
Configure::write('debug', 0);
make that 2 or 1.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 17, 2020 2:43 am

Thanks! I'll close this thread here and pick back up on my one under viewtopic.php?f=40&t=29428.

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Thu May 28, 2020 7:28 pm

Just wanted to follow up...

Rather out of the blue zmNinja started being able to connect up to Monitors and all else. I really have no idea what exactly caused this to occur: I ran into some socket errors on the server running from a web browser and when kicking the Bandwidth setting down to Medium/Low the errors went away.

HUGE relief to have zmNinja working again! (never zmNinja's issue/fault! even so, the developer still tried to help out [that's customer service!])

User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Re: Another API issue..

Post by asker » Fri May 29, 2020 10:53 am

All's well that ends well!
Enjoy ZM/zmNinja
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Fri May 29, 2020 7:54 pm

Ugh... I'm back to having problems. Likely NOT a zmNinja issue, though I'm reporting here to help [re]direct others.

Live stream works, but event playback (on my Android phone) does not. Seems that I might have TWO separate issues teaming up on me here. And it is affecting Event playback.

Under IOS (just installed zmNinja) and on a Linux desktop (browser OR zmNinja) Event playback mostly works, but it sometimes hangs and I'm getting socket errors in ZM's logs. This appears to be a network issues of some sort. Remote access (not on/adjacent to ZM network) seems prone to this.

Under Android, Event playback goes through downloading but then fails to play the video. I get nothing logged in ZM's logs for this. It would seem as though this might be a device/browser issue: nothing has changed on this phone; it worked perfectly fine for ZM 1.30.4. No playback via web browser either: Chrome gives me: "The video playback was aborted due to a corruption problem or because the video used features your browser did not support."

Setting monitor resolution low (640x400) had no bearing for my Android phone: same as above error.

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Fri May 29, 2020 9:21 pm

OK, I've found the cause of the Android phone issue. CODEC is set to Auto by default. I can change this within a browser, but not within zmNinja. If, within a browser, I set it to MJPEG it will display (though I'm still subjected to socket issues, which is a separate, though previously commented on, issue). According to ZM's documentation blanking out MPEG_REPLAY_FORMAT defaults to MJPEG, but this is not how it comes out on the client side! Further, it seems that setting it to MJPEG also does not make it come out as such on the client side: I don't know if this affects how it was recorded or not; if so, then that's the reason- I have not tested/checked for this.

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 31, 2020 1:59 am

I disabled Chrome and installed WebView but that doesn't rectify; perhaps there's some setting to make zmNinja see/understand this? Again, I can view event playback while logged in to the ZM console via Firefox, though I have to specify MJPEG as the codec.

Logs (which I can provide, but just wanted to be brief for now) all in order except this part:

... DEBUG API-Total length:8
... DEBUG Player-Total length:0

The event IS 8 seconds, so that's OK. But, why is it reporting that the player length is 0?

Is there a location where the downloaded video files go to?

I get thumbnails and alarm frames, and the video seems to be downloaded.

User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Re: Another API issue..

Post by asker » Sun May 31, 2020 6:30 pm

So in general, I've seen this:

That is, a mobile browser plays the video, but the embedded chrome browser inside zmNinja does not. I have no idea why. So far, its been solved by playing with the recorded video size in ZM, and potentially its format in ZM settings.
I think you have come closest to the core issue - codec format. I have no clue how to switch the codec format inside zmNinja.

My only suggestion right now is to debug more and enlighten me if you find a way around. I also wonder if its any help if you change the FFMPEG options in ZM. There is another person who is facing a playback issue, I've asked him to chip in here I we can figure it out.

Can one of you give me access to your ZM portal with a test account and some events that don't play? I'll give it a shot with zmNinja and see what I find.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 31, 2020 7:01 pm

Sent you message. You should have access to any events (though any single one of them ought to be OK). If you can help me figure out ADB again I can dig deeper. One thing not mentioned is that my phone's rooted: not sure if I'd read of this presenting any issues w/regard to zmNinja.

Many thanks.

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 31, 2020 7:26 pm

I'm a bit confused over ZM's info for MPEG_REPLAY_FORMAT:
When using MPEG mode ZoneMinder can replay events in encoded video format. However what formats are handled by the browser varies greatly between machines. This option allows you to specify a video format using a file extension format, so you would just enter the extension of the file type you would like and the rest is determined from that. The default of 'asf' works well under Windows with Windows Media Player and 'mpg', or 'avi' etc should work under Linux. If you know any more then please let me know! If this option is left blank then live streams will revert to being in motion jpeg format
They're using "replay" and "live." Which does this really affect? As it has "REPLAY" in the name I figure it was an association for playback. I've currently got it set to MJPEG (an attempt to get zmNinja's playback to work on my Android). Setting to "mpg" didn't work. Haven't tried "avi."

Note that I continue to get socket errors. I do not believe it's a fundamental configuration issue as in some instances things seem to work without triggering such errors. Doesn't seem to be the source of the zmNinja issue I'm experiencing, it's just another issue that's there to distract...

User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Re: Another API issue..

Post by asker » Sun May 31, 2020 8:47 pm

So interestingly, my android device (Moto E, Android 8 ) plays your videos (as does my IOS device).
I played Event-301. Took quite some time to download and then play, but it did play

I don't think all the MPEG format settings will affect video playback when they are stored as MP4. My guess is the ffmpeg input options may affect things. (Not 100% sure, I've never used mpeg mode in ZM, but it seems like this is related to either live playback, or playback via zms,neither of which is used in the situation you are debugging - MP4 videos not playing)
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Re: Another API issue..

Post by asker » Sun May 31, 2020 9:05 pm

I am also going to leave this here for investigation:
https://stackoverflow.com/questions/135 ... ing-ffmpeg
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 31, 2020 9:11 pm

It figures it only bites the hand that feeds it (me)! :shock:

Event 301 is only 9 seconds. Maybe I need to really kick the resolution down? I'm a bit hesitant to lose quality though (of course, what good is quality if you can't use it).

I'm running Android 7.0. It's a generic kernel: I rooted it so I could run a battery limiter on it- I keep it plugged in to my car all the time). Don't think it's updating at all, so there might be some updates that are needed. I might try my wife's old G4+ (which isn't rooted).

I noted several of the following ZM log errors, which I'm figuring is related to you logging in (I see no other errors, which is interesting).

Code: Select all

Unable to authenticate user. error decoding JWT token:Signature verification failed
Seems that I always am getting a socket error logged whenever I try to view events.

SkippyDo
Posts: 186
Joined: Mon Nov 20, 2017 6:49 pm

Re: Another API issue..

Post by SkippyDo » Sun May 31, 2020 9:15 pm

Bit rate is something I'm pondering. Going to wait to first try out my wife's old G4+ (mine's a plain G4, older).

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests