ZoneMinder / zmNinja

High performance, cross platform ionic app for Home/Commerical Security Surveillance using ZoneMinder
http://zmninja.zoneminder.com
Other
1.01k stars 268 forks source link

zmninja cannot talk to zmeventserver #136

Closed pliablepixels closed 8 years ago

pliablepixels commented 8 years ago

Continuation of https://github.com/pliablepixels/zmeventserver/issues/5

@g4dge reports that zmNinja cannot connect to zmeventserver

@g4dge, based on your logs, please check the following:

a) That you have configured your WSS URL correctly - the logs strip the server name out for privacy, so I don't know what you have there

b) That you have installed the SSL certificate in the phone - other wise it won't be able to connect

pliablepixels commented 8 years ago

Hmm, so it looks like someone is able to connect but keeps disconnecting

Jan 9 20:09:53 behemoth zmeventnotification[21102]: INF [Websocket remotely disconnected from ::ffff:10.1.1.19]
Jan 9 20:09:57 behemoth zmeventnotification[21102]: INF [got a websocket connection from ::ffff:10.1.1.19 (0) active connections]

Can you please enable DEBUG logs in zmNinja as well? (Developer settings)

g4dge commented 8 years ago

I've just mailed this over... Thank you very much for taking the time to look at my problem!

g4dge commented 8 years ago

For the benefit of others...

Jan 11, 2016 12:22:45 AM INFO Websocket closed Jan 11, 2016 12:22:41 AM INFO Websocket closed Jan 11, 2016 12:22:38 AM INFO Websocket closed Jan 11, 2016 12:22:32 AM INFO Websocket closed Jan 11, 2016 12:22:29 AM INFO Websocket closed Jan 11, 2016 12:22:24 AM INFO Websocket closed Jan 11, 2016 12:22:19 AM INFO Websocket closed Jan 11, 2016 12:22:13 AM INFO Websocket closed Jan 11, 2016 12:22:08 AM INFO Websocket closed Jan 11, 2016 12:22:06 AM INFO Stream authentication construction: Jan 11, 2016 12:22:06 AM INFO Data Model: Did not find any stream mode of auth Jan 11, 2016 12:22:06 AM INFO DataModel: Did not find a stream auth key, looking for user= Jan 11, 2016 12:22:06 AM INFO Got API version: 1.29.0 Jan 11, 2016 12:22:06 AM INFO ZM_EVENT_IMAGE_DIGITS is 5 Jan 11, 2016 12:22:06 AM INFO Returning pre-loaded list of 4 monitors Jan 11, 2016 12:22:06 AM DEBUG getAPIversion called Jan 11, 2016 12:22:06 AM DEBUG events Jan 11, 2016 12:22:06 AM DEBUG Config URL for digits is:http:///api/configs/viewByName/ZM_EVENT_IMAGE_DIGITS.json Jan 11, 2016 12:22:06 AM DEBUG PortalLogin: auth success Jan 11, 2016 12:22:06 AM DEBUG DataModel: Getting auth from http:///index.php?view=watch&mid=3 with mid=3 Jan 11, 2016 12:22:06 AM DEBUG auth-success emit:Successful Jan 11, 2016 12:22:06 AM INFO zmAutologin successfully logged into Zoneminder Jan 11, 2016 12:22:06 AM INFO ZM has recaptcha disabled - good Jan 11, 2016 12:22:05 AM INFO Checking if reCaptcha is enabled in ZM... Jan 11, 2016 12:22:05 AM INFO zmAutologin called Jan 11, 2016 12:22:05 AM INFO Cancelling zmAutologin timer Jan 11, 2016 12:22:05 AM DEBUG PIN code not set Jan 11, 2016 12:22:05 AM INFO not checking for touchID Jan 11, 2016 12:22:05 AM INFO User credentials are provided Jan 11, 2016 12:22:05 AM DEBUG Inside Portal login Enter handler Jan 11, 2016 12:22:05 AM INFO using nph - no timers needed Jan 11, 2016 12:22:05 AM INFO ModalCtrl: Restarting Modal timer on resume Jan 11, 2016 12:22:05 AM DEBUG ModalCtrl: Modal resume called Jan 11, 2016 12:22:05 AM INFO Restarting montage timer on resume Jan 11, 2016 12:22:05 AM DEBUG MontageCtrl: onresume called Jan 11, 2016 12:22:05 AM DEBUG Last State recorded:{"viewId":"ion20","index":0,"historyId":"ion2","backViewId":null,"forwardViewId":null,"stateId":"events_id=0","stateName":"events","stateParams":{"id":"0"},"url":"/events/0","canSwipeBack":true} Jan 11, 2016 12:22:05 AM INFO App is resuming from background Jan 11, 2016 12:21:39 AM INFO Websocket closed Jan 11, 2016 12:21:22 AM INFO Cancelling zmAutologin timer Jan 11, 2016 12:21:22 AM INFO App is going into background Jan 11, 2016 12:21:22 AM INFO Websocket closed Jan 11, 2016 12:21:17 AM INFO Websocket closed Jan 11, 2016 12:21:05 AM INFO Websocket closed Jan 11, 2016 12:20:58 AM INFO Websocket closed Jan 11, 2016 12:20:52 AM INFO Websocket closed Jan 11, 2016 12:20:50 AM INFO Websocket closed Jan 11, 2016 12:20:45 AM INFO Websocket closed Jan 11, 2016 12:20:37 AM INFO Websocket closed Jan 11, 2016 12:20:33 AM INFO Websocket closed Jan 11, 2016 12:20:26 AM INFO Websocket closed Jan 11, 2016 12:20:23 AM INFO Websocket closed Jan 11, 2016 12:20:23 AM INFO Modal: Stream authentication construction: Jan 11, 2016 12:20:23 AM INFO Data Model: Did not find any stream mode of auth Jan 11, 2016 12:20:23 AM INFO DataModel: Did not find a stream auth key, looking for user= Jan 11, 2016 12:20:22 AM DEBUG EventCtrl:loading one more page just in case we don't have enough to display Jan 11, 2016 12:20:22 AM DEBUG EventCtrl: success, got 25 events Jan 11, 2016 12:20:22 AM DEBUG EventCtrl: grabbing events for: id=0 Date/Time:- Jan 11, 2016 12:20:22 AM DEBUG EventCtrl: found 1 pages of events Jan 11, 2016 12:20:22 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 12:20:22 AM INFO Websocket closed Jan 11, 2016 12:20:22 AM DEBUG Sending token state disabled Jan 11, 2016 12:20:22 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 12:20:22 AM DEBUG Sending Control message 'filter' with monlist=3 and interval=60 Jan 11, 2016 12:20:22 AM INFO Image padding digits reported as 5 Jan 11, 2016 12:20:22 AM INFO Image padding digits reported as 5 Jan 11, 2016 12:20:22 AM DEBUG Event server already initialized Jan 11, 2016 12:20:22 AM DEBUG Saving Event Server data Jan 11, 2016 12:20:22 AM INFO Using nph-zms, no timer needed Jan 11, 2016 12:20:22 AM DEBUG DataModel: Getting auth from http:///index.php?view=watch&mid=3 with mid=3 Jan 11, 2016 12:20:22 AM DEBUG Setting playback to jpeg Jan 11, 2016 12:20:22 AM INFO ZM_EVENT_IMAGE_DIGITS is already configured for 5 Jan 11, 2016 12:20:22 AM DEBUG EventCtrl: grabbing # of event pages Jan 11, 2016 12:20:22 AM INFO ZM_EVENT_IMAGE_DIGITS is already configured for 5 Jan 11, 2016 12:20:22 AM INFO Returning pre-loaded list of 4 monitors Jan 11, 2016 12:20:20 AM INFO Websocket closed Jan 11, 2016 12:20:15 AM INFO Websocket closed Jan 11, 2016 12:20:10 AM INFO Websocket closed Jan 11, 2016 12:20:07 AM DEBUG Modal is closed, so toggling or exiting Jan 11, 2016 12:20:05 AM INFO Websocket closed Jan 11, 2016 12:20:05 AM INFO Websocket closed Jan 11, 2016 12:20:05 AM DEBUG Sending token state disabled Jan 11, 2016 12:20:05 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 12:20:05 AM DEBUG Sending Control message 'filter' with monlist=3 and interval=60 Jan 11, 2016 12:20:05 AM DEBUG Event server already initialized Jan 11, 2016 12:20:05 AM DEBUG Saving Event Server data Jan 11, 2016 12:20:00 AM INFO Websocket closed Jan 11, 2016 12:20:00 AM INFO Returning pre-loaded list of 4 monitors Jan 11, 2016 12:20:00 AM DEBUG DataModel/setLogin: writing {"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-bin","maxFPS":"3","montageQuality":"50","singleImageQuality":"50","useSSL":false,"keepAwake":true,"isUseAuth":"1","isUseEventServer":"1","disablePush":"1","eventServerMonitors":"3","eventServerInterval":"60","refreshSec":"2","enableDebug":true,"usePin":false,"pinCode":"","canSwipeMonitors":true,"persistMontageOrder":false,"onTapScreen":"events","enableh264":true,"gapless":true,"montageOrder":"","montageHiddenOrder":"","montageArraySize":"1:1:1","graphSize":200,"minAlarmCount":"1","montageSize":"1","useNphZms":true} Jan 11, 2016 12:20:00 AM INFO Saving all parameters to storage Jan 11, 2016 12:20:00 AM DEBUG Saving settings before going to Event Server settings Jan 11, 2016 12:19:57 AM DEBUG DataModel/setLogin: writing {"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-bin","maxFPS":"3","montageQuality":"50","singleImageQuality":"50","useSSL":false,"keepAwake":true,"isUseAuth":"1","isUseEventServer":"1","disablePush":"1","eventServerMonitors":"3","eventServerInterval":"60","refreshSec":"2","enableDebug":true,"usePin":false,"pinCode":"","canSwipeMonitors":true,"persistMontageOrder":false,"onTapScreen":"events","enableh264":true,"gapless":true,"montageOrder":"","montageHiddenOrder":"","montageArraySize":"1:1:1","graphSize":200,"minAlarmCount":"1","montageSize":"1","useNphZms":true} Jan 11, 2016 12:19:57 AM INFO Saving all parameters to storage Jan 11, 2016 12:19:57 AM DEBUG SaveDevOptions: Saving to disk Jan 11, 2016 12:19:57 AM DEBUG SaveDevOptions: called Jan 11, 2016 12:19:55 AM INFO Websocket closed Jan 11, 2016 12:19:52 AM DEBUG DataModel/setLogin: writing {"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-bin","maxFPS":"3","montageQuality":"50","singleImageQuality":"50","useSSL":false,"keepAwake":true,"isUseAuth":"1","isUseEventServer":"1","disablePush":"1","eventServerMonitors":"3","eventServerInterval":"60","refreshSec":"2","enableDebug":true,"usePin":false,"pinCode":"","canSwipeMonitors":true,"persistMontageOrder":false,"onTapScreen":"events","enableh264":true,"gapless":true,"montageOrder":"","montageHiddenOrder":"","montageArraySize":"1:1:1","graphSize":200,"minAlarmCount":"1","montageSize":"1","useNphZms":true} Jan 11, 2016 12:19:52 AM INFO Saving all parameters to storage Jan 11, 2016 12:19:52 AM DEBUG SaveDevOptions: Saving to disk Jan 11, 2016 12:19:52 AM DEBUG SaveDevOptions: called Jan 11, 2016 12:19:50 AM INFO Websocket closed Jan 11, 2016 12:19:45 AM INFO Websocket closed Jan 11, 2016 12:19:42 AM INFO Websocket closed Jan 11, 2016 12:19:42 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 12:19:41 AM INFO Stream authentication construction: Jan 11, 2016 12:19:41 AM INFO Data Model: Did not find any stream mode of auth Jan 11, 2016 12:19:41 AM INFO DataModel: Did not find a stream auth key, looking for user= Jan 11, 2016 12:19:41 AM INFO Stored montage order does not exist Jan 11, 2016 12:19:41 AM INFO Inside Montage Ctrl:We found 4 monitors Jan 11, 2016 12:19:41 AM INFO Stored montage order does not exist Jan 11, 2016 12:19:41 AM INFO Monitor load was successful, loaded 4 monitors Jan 11, 2016 12:19:40 AM INFO ZM_EVENT_IMAGE_DIGITS is 5 Jan 11, 2016 12:19:40 AM INFO Got API version: 1.29.0 Jan 11, 2016 12:19:40 AM INFO Websocket closed Jan 11, 2016 12:19:40 AM INFO ZM has recaptcha disabled - good Jan 11, 2016 12:19:40 AM INFO Stream authentication construction: Jan 11, 2016 12:19:40 AM INFO getMonitors:Loading all monitors Jan 11, 2016 12:19:40 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 12:19:40 AM INFO Deferring auth key, as monitorId unknown Jan 11, 2016 12:19:40 AM INFO zmAutologin successfully logged into Zoneminder Jan 11, 2016 12:19:40 AM INFO Checking if reCaptcha is enabled in ZM... Jan 11, 2016 12:19:40 AM INFO zmAutologin called Jan 11, 2016 12:19:40 AM INFO Cancelling zmAutologin timer Jan 11, 2016 12:19:40 AM INFO not checking for touchID Jan 11, 2016 12:19:40 AM INFO User credentials are provided Jan 11, 2016 12:19:39 AM INFO zmNinja Version: 1.0.2 Jan 11, 2016 12:19:39 AM INFO Deleting old log file as it exceeds 10000 bytes 2016-01-11T00:19:39.099Z INFO Initializing Websocket with URL wss:// , will connect later... 2016-01-11T00:19:39.088Z INFO Setting up push registration 2016-01-11T00:19:39.087Z INFO DataModel init recovered this loginData as {"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-bin","maxFPS":"3","montageQuality":"50","singleImageQuality":"50","useSSL":false,"keepAwake":true,"isUseAuth":"1","isUseEventServer":"1","disablePush":"1","eventServerMonitors":"3","eventServerInterval":"60","refreshSec":"2","enableDebug":false,"usePin":false,"pinCode":"","canSwipeMonitors":true,"persistMontageOrder":false,"onTapScreen":"events","enableh264":true,"gapless":true,"montageOrder":"","montageHiddenOrder":"","montageArraySize":"1:1:1","graphSize":200,"minAlarmCount":"1","montageSize":"1","useNphZms":true} 2016-01-11T00:19:39.073Z INFO ZMData init: checking for stored variables & setting up log file 2016-01-11T00:19:39.063Z INFO Device is ready

pliablepixels commented 8 years ago

Folks, my push server is down - I am on travel till 17th of Jan - not quite sure what happened, but till then you won't get push notifications on your phone in the background - sorry about that. Its supposed to restart but hasn't

@g4dge are you sure you have installed the SSL certificates on the phone - the same one that zmeventserver uses?

pliablepixels commented 8 years ago

There is something wrong in your configuration

{"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-

Can you re-check what you have entered? The logs should show http://<server>/ and wss://<server>:9000/ instead of null strings

g4dge commented 8 years ago

Thanks for the continued feedback and support on this issue...

I'd not previously seen this guide before (https://github.com/pliablepixels/zmNinja/blob/master/docs/SSL-Configuration.md#install-certificates-cer-file-in-yout-phone), might be useful to link to it from your event server readme.

I'm not using SSL, nor was I using authentication between my desktop clients and ZM, since I've got it all behind a VPN and firewall. I've switched on authentication, and generated the keys as that was mentioned on eventserver readme (https://github.com/pliablepixels/zmeventserver/blob/master/README.md) - this was based on your comment - If you are not already using SSL for ZoneMinder and don't have certificates, generating them is as easy as: - I admit I just spammed return to get these created using default values.

I've attached logs from today, as well as some screenshots from the app. Looks like I've got a registrationid, which is something I've not seen previously.

Jan 11, 2016 11:39:24 AM DEBUG DataModel/setLogin: writing {"serverName":"Behemoth","username":"","password":"","url":"http://","apiurl":"http:///api","eventServer":"wss://","maxMontage":"10","streamingurl":"http:///cgi-bin","maxFPS":"3","montageQuality":"50","singleImageQuality":"50","useSSL":false,"keepAwake":true,"isUseAuth":"1","isUseEventServer":"1","disablePush":"1","eventServerMonitors":"3","eventServerInterval":"60","refreshSec":"2","enableDebug":true,"usePin":false,"pinCode":"","canSwipeMonitors":true,"persistMontageOrder":false,"onTapScreen":"events","enableh264":true,"gapless":true,"montageOrder":"","montageHiddenOrder":"","montageArraySize":"1:1:1","graphSize":200,"minAlarmCount":"1","montageSize":"1","useNphZms":true} Jan 11, 2016 11:39:24 AM INFO Saving all parameters to storage Jan 11, 2016 11:39:24 AM DEBUG Saving settings before going to Event Server settings Jan 11, 2016 11:39:20 AM INFO Websocket closed Jan 11, 2016 11:39:15 AM INFO Websocket closed Jan 11, 2016 11:39:10 AM INFO Websocket closed Jan 11, 2016 11:39:10 AM INFO Websocket closed Jan 11, 2016 11:39:09 AM INFO Websocket was closed, trying to re-open Jan 11, 2016 11:39:09 AM DEBUG Push Notification registration ID received: {"registrationId":"APA91bHKlY2ZYxMOfdXMP6rT34vH1hjOeH8xQFIQCklepE2zQZNG8L08fHC5G104MGhtTc0Zfs2MyeIupBBpRBZzNW30NwgE1cNKA1fGBgWnKU9Yo8Sk17k8dheZCMaVa4wkZR5vq-vw"}

screenshot_2016-01-11-11-44-46

screenshot_2016-01-11-11-44-51

screenshot_2016-01-11-11-44-20

pliablepixels commented 8 years ago

Okay so that's the problem

The event server uses SSL (WSS == Web Sockets Secure/SSL) so you need to have the certificates both generated at the event server and installed in the phone. I'll add the install to phone part to the readme

When generating the certificate its very important to make sure the "common name" is the same server hostname or IP you will use. In your case its 10.1.3

Once you install the certificate in your phone you should be able to connect

The "registration ID" is a push notification id - it still shows you can't connect to your event server.

g4dge commented 8 years ago

Thank you very much, I'll give it a try and report back later today!

g4dge commented 8 years ago

Hey,,,

So regenerated the key, and restarted both apache and zoneminder. Got the following once I fired up the app.

Jan 11 22:03:24 behemoth zmeventnotification[10829]: INF [got a websocket connection from ::ffff:10.1.1.19 (0) active connections] Jan 11 22:03:24 behemoth zmeventnotification[10829]: INF [Websockets: New Connection Handshake requested from ::ffff:10.1.1.19:52930 state=pending auth] Jan 11 22:03:25 behemoth zmeventnotification[10829]: INF [Correct authentication provided by ::ffff:10.1.1.19] Jan 11 22:03:25 behemoth zmeventnotification[10829]: INF [Storing token ...wkZR5vq-vw,monlist:-1,intlist:-1,pushstate:disabled] Jan 11 22:03:25 behemoth zmeventnotification[10829]: INF [Pushproxy registration success ] Jan 11 22:03:25 behemoth zmeventnotification[10829]: INF [Storing token ...wkZR5vq-vw,monlist:-1,intlist:-1,pushstate:disabled] Jan 11 22:03:26 behemoth zmeventnotification[10829]: INF [Pushproxy registration success ] Jan 11 22:03:40 behemoth zmeventnotification[10829]: INF [Contrl: Storing token ...wkZR5vq-vw,monlist:3,intlist:60,pushstate:disabled] Jan 11 22:03:40 behemoth zmeventnotification[10829]: INF [Pushproxy registration success ]

Then forced an alert...

Jan 11 22:06:28 behemoth zmeventnotification[10829]: INF [New event 479 reported for HD-Feed] Jan 11 22:06:28 behemoth zmeventnotification[10829]: INF [Broadcasting new events to all 1 websocket clients] Jan 11 22:06:29 behemoth zmeventnotification[10829]: INF [Checking alarm rules for ::ffff:10.1.1.19:52930 token ending in:...wkZR5vq-vw] Jan 11 22:06:29 behemoth zmeventnotification[10829]: INF [Monitor 3 event: last time not found, so sending] Jan 11 22:06:29 behemoth zmeventnotification[10829]: INF [::ffff:10.1.1.19-sending over websockets] Jan 11 22:07:08 behemoth zmeventnotification[10829]: INF [Total event client connections: 1] Jan 11 22:07:08 behemoth zmeventnotification[10829]: INF [Reloading Monitors...] Jan 11 22:07:08 behemoth zmeventnotification[10829]: INF [Loading monitors]

Now, I've yet to recieve anything to my phone, but then I'm guessing that's because your push proxy is down.

Hopefully this is a clean bill of health, could you cast your eye and let me know if it looks good.

Once again thank you very much for all your assistance through this, and making this excellent app and tool!

Cheers

Rob

pliablepixels commented 8 years ago

Awesome, you are almost there. My push proxy is up again.

Jan 11 22:03:40 behemoth zmeventnotification[10829]: INF [Contrl: Storing token ...wkZR5vq-vw,monlist:3,intlist:60,pushstate:disabled]

This log says your phone has not enabled push notifications. Please ensure that a) you have not blocked push notifications for this app in android b) You have the "use only web sockets" toggle button to OFF on event server

When you see a log in the event server that says "push state:enabled" you are all set

g4dge commented 8 years ago

Hi There,

I've now got everything working, and I've tested a few scenarios upon my phone to confirm that it comes through. Thanks very much for your guidance and support in getting this in place.

One slight request if I may be so cheeky -

Have you heard of pushover? It's a free(ish - paid app / 7,500 messages per month limit).

https://pushover.net/faq#library-perl

I think that this would integrate fairly easy with zmeventnotification, and could be a third method of sending alerts. for those that don't wish to run WSS.

As I see it there are the following benefits.

+Simple user config (No WSS, or putting SSL keys onto phone) +No requirement to open firewall ports / setup port forwarding +Push notifications are saved to phone, and can be reviewed (as opposed to just seeing the latest) +Allows for customisation of alert tone, and severity +Alerts can be grouped (based on setting up an API within an individuals pushover account) +You're push proxy won't be hammered as hard (and chatty users have an option to buy more pushes)

-I don't think that this would automatically fire up zmNinja (however it would certainly alert me to needing to go there).

If you could consider this it would be very much appreciated! However appreciate how busy you must be, especially given the time that you share with your users.

Keep up the good work!

Best wishes

Rob

pliablepixels commented 8 years ago

Thanks Rob - glad you have it resolved. Yes, I am aware of these 3rd party push servers - hopefully sometime in the future :)