vectronic / homebridge-shinobi

A Homebridge plugin integrating Shinobi for motion detector cameras

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid URL in logs

jaxonashton opened this issue · comments

I recently decided to try the Shinobi plugin for HB to see if it offers any advantages over the FFmpeg plugin. So far so good: I've been able to add my cameras ("monitors") without issue. Except that when I attempt to view them, I get an invalid url response in the logs:

[10/06/2022, 13:04:54] [homebridge-shinobi] handleSnapshotRequest() error: Invalid URL

Troubleshooting with the API docs got me to the point of using the direct URL (http://192.168.8.9:8080/[MyAPIkey]/monitor/[GroupKey]) in my browser to see what response is returned:

{
  "ok": false,
  "msg": "Not Authorized"
}

However, I've double-checked my API key three different times and it's exactly as it's provided in the API settings of Shinobi. Can't seem to figure this one out.

I’ll have a look in the next few days and see what I can see.

So just to clarify, you have Shinobi installed and running?

https://shinobi.video

I am using the latest from git master. (Updated just now as I am having problems with thumbnails not displaying which I can't seem to get working. Anyway I digress...)

Is Shinobi running on a different IP or different port to the Homebridge server?

From a browser (or better from a terminal where Homebridge server is installed) you should be able to access the following (completely outside of Homebridge plugin) and get back JSON config:

browser: http://<shinobi_api>/<api_key>/monitor/<group_key>

terminal: curl http://<shinobi_api>/<api_key>/monitor/<group_key>

If you can't get that working then I suspect an issue with Shinobi config or auth settings: https://shinobi.video/docs/api

NOTE: I haven't configured 2 Factor Auth so maybe this plugin doesn't work if you have that enabled in Shinobi.

Otherwise, this is how I have my Shinobi instance setup:

Screenshot 2022-06-13 at 15 41 49

@vectronic I reconfigured my API key based on the settings you specified in your screenshot. I am getting a positive response now with both http://<shinobi_api>/<api_key>/monitor/<group_key> and curl http://<shinobi_api>/<api_key>/monitor/<group_key> (the curl works both on the raspy running HB and Shinobi as well as on another machine on the same LAN). However, I persist in getting [homebridge-shinobi] handleSnapshotRequest() error: Invalid URL in my HB logs whenever I go to view a camera, and HomeKit displays the following:

IMG_DECA8722F8D8-1

I can confirm I do not have 2FA enabled in Shinobi.

The error you are getting is logged at this line:

https://github.com/vectronic/homebridge-shinobi/blob/master/src/shinobiStreamingDelegate.ts#L93

If you start homebridge with debug logging:

homebridge -D

then this line should log as well:

https://github.com/vectronic/homebridge-shinobi/blob/master/src/shinobiStreamingDelegate.ts#L83-L84

which should show the URL being requested.

The URL should "theoretically" be the same that you are successfully accessing with curl. I am guessing that there is a chance the config you are getting from the Shinobi API is different to what I get and therefore this plugin is parsing the config incorrectly and getting the wrong URL.

If you can establish what URL is requested and see if this is wrong, the best thing would be to post the result of the following and I can try to see where my parsing is breaking:

curl http://<shinobi_api>/<api_key>/monitor/<group_key

Also, just for reference here is my config (redacted):

Screenshot 2022-06-14 at 13 34 29

The URL should "theoretically" be the same that you are successfully accessing with curl. I am guessing that there is a chance the config you are getting from the Shinobi API is different to what I get and therefore this plugin is parsing the config incorrectly and getting the wrong URL.

It appears that it's trying to do a callback to http://192.168.8.9:8080undefined for some reason, instead of the curl URL of http://192.168.8.9:8080/[API]/monitor/[GROUP]/[MONITOR], which btw, still continues to load in the browser and curl successfully.

If you can establish what URL is requested and see if this is wrong, the best thing would be to post the result of the following and I can try to see where my parsing is breaking:

curl http://<shinobi_api>/<api_key>/monitor/<group_key

I'll drop it in this Gist.

Also, just for reference here is my config (redacted):

Screenshot 2022-06-14 at 13 34 29

This is a redacted copy of my config as well, for comparison:

Screenshot at Jun 14 09-40-18

Image preview issue was solved by enabling JPEG API for each monitor in the Shinobi configuration. Updated README accordingly.