Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token < in JSON at position 1 #94

Open
Timdebruijn opened this issue Sep 14, 2021 · 2 comments
Open

Unexpected token < in JSON at position 1 #94

Timdebruijn opened this issue Sep 14, 2021 · 2 comments

Comments

@Timdebruijn
Copy link

Describe the bug
Homebridge can't access API

Specifications
What hardware and OS is your Homebridge running on?
A VM in VMware ESXI7, i5-8500T, 2GB ram, Ubuntu 20.04, Home bridge v1.3.4, homebridge-unifi-protect-camera-motion v0.4.5
The Unifi hardware:
Cloud Key Gen2 Plus, firmware 2.1.11, protect 1.19.0

Logging

[9/14/2021, 1:30:25 PM] ---
[9/14/2021, 1:30:25 PM] Loaded plugin: [email protected]
[9/14/2021, 1:30:25 PM] Registering platform 'homebridge-config-ui-x.config'
[9/14/2021, 1:30:25 PM] ---
2021-09-14 13:30:26.101181: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-09-14 13:30:26.116694: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2112000000 Hz
2021-09-14 13:30:26.117013: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x66848d0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-09-14 13:30:26.117034: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
[9/14/2021, 1:30:26 PM] Loaded plugin: [email protected]
[9/14/2021, 1:30:26 PM] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion'
[9/14/2021, 1:30:26 PM] ---
[9/14/2021, 1:30:26 PM] Loading 2 platforms...
[9/14/2021, 1:30:26 PM] [Config] Initializing config platform...
[9/14/2021, 1:30:26 PM] [Config] Running in Service Mode
[9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Initializing UnifiProtectMotion platform...
Preparing Advertiser for 'Homebridge 1650 XXX' using bonjour-hap backend!
Setup Payload:
X-HM:https://00242XXXXXX
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

┌────────────┐     
│ XXX-XX-XXX │     
└────────────┘     

Starting to advertise 'Homebridge 1650 DF75' using bonjour-hap backend!
[9/14/2021, 1:30:26 PM] Homebridge v1.3.4 (Homebridge 1650) is running on port 51411.
[9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS
[9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: FetchError: invalid json response body at https://192.x.x.x/protect/proxy/protect/api/bootstrap reason: Unexpected token < in JSON at position 1
[9/14/2021, 1:30:28 PM] [Unifi protect cameras & motion sensors] Motion checking setup done!

To Reproduce
Steps to reproduce the behavior:

  1. start the server with the plugin

Expected behavior
Not the fetch error

@beele
Copy link
Owner

beele commented Oct 30, 2021

I'm also using UnifiOs and cannot reproduce this issue

@dpankros
Copy link

In the overwhelming majority of situations, that error is caused by a web server returning an error and, instead of providing JSON as requested, it's sending an error HTML page. (The "<" is the first character of the HTML page, but is illegal in JSON at that position and, hence, the error.)
The first thing I'd do is to manually hit that url and see what you get:
curl -vl 'https://192.x.x.x/protect/proxy/protect/api/bootstrap'
I don't know if it's a POST or GET, but that should work for a GET. For a POST, we'd need to know what payload is being sent to get a reliable response. If it returns an error, try to figure out why (bad URL, for example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants