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

Gateway polling gives cryptic error message when no API key is provided #8

Open
TimVog opened this issue Oct 29, 2022 · 2 comments
Open

Comments

@TimVog
Copy link

TimVog commented Oct 29, 2022

Hi,
first of all thanks for the great program. My goal is to have my ruuvi gateway (firmware v1.12.4) collect the data from my 6 ruuvi pro sensors (firmware v.3.31.1) and send it to my local server, where I can display it with Grafana.

I was following the tutorial from ruuvi to set-up an installation for receiving the data, https://ruuvi.com/connecting-ruuvi-gateway-to-a-private-server/ but it failed at the glue logic.

Afterwards, I found your program which seems to be just the right fit. Unfortunately, neither of the 3 offered methods (to receive data from the gateway) seem to work at first.

  1. My first try with RuuviBridge was polling the data from the gateway.
    I can access the gateway in the local network, and had it fully set-up

Ruuvi Gateway’s IP address:
192.168.1.144
Subnet mask:
255.255.255.0
Gateway:
192.168.1.1
DHCP server:
192.168.1.1

and can see the history under http://192.168.1.144/history
history.json.txt

root@debianvm:/home/tim/ruuvi_bridge# docker-compose up
Starting ruuvibridge ... done
Attaching to ruuvibridge
ruuvibridge    | [2022-10-29 10:14:56] [info] RuuviBridge starting up, version: git-01695bace9705e53f52735e6e15640f39125ce9c
ruuvibridge    | [2022-10-29 10:14:56] [info] Starting data sources
ruuvibridge    | [2022-10-29 10:14:56] [info] Starting gateway polling, target: http://192.168.1.144, interval: 10s
ruuvibridge    | [2022-10-29 10:14:56] [info] Starting data sinks
ruuvibridge    | [2022-10-29 10:14:56] [info] Starting InfluxDB sink, minimum_interval: 0s, target: http://192.168.1.69:8086, bucket: ruuvi, measurement_name: ruuvi_measurements
ruuvibridge    | [2022-10-29 10:14:56] [info] Starting processing
ruuvibridge    | [2022-10-29 10:14:56] [error] Failed to get history from gateway, target: http://192.168.1.144, interval: 10s, error: Get "http://192.168.1.144/history": net/http: HTTP/1.x transport connection broken: unexpected EOF

Mosquitto also had problems (I guess this is a problem from Docker and how to forward ports, I don't have experience with Docker) and the third HTTP method stayed silent and never received data. So I went back to the first method, where RuuviBridge is polling the data.

Going back to the first HTTP/1.x error, I though that the data format from ruuvi maybe changed (since I had no problem to download the history data on the browser). It turns outs, that during setup of the Ruuvi gateway it should be not optional to take the API key, but is absolutely necessary to copy it and place it in the config.yml of RuuviBridge. Maybe I missed it in the description, but it would be great if you can add to the comment that it is necessary to add the API key.

@Scrin
Copy link
Owner

Scrin commented Oct 29, 2022

Running mosquitto in Docker requires proper forwarding of ports, as does the "third option" ("HTTP pushing" from the gateway), so the issue with both of those is/was probably with your Docker setup regarding ports

About the polling and the api key: the addition of an api key (bearer token) is a relatively new feature on the gateway, and the previous "recommended way" to run the setup was with authentication disabled on the gateway, since authentication would add an unnecessary amount of hassle without an api key. The same still works, you can run the gateway without authentication and in that case you don't have to copy the api key

On top of that, there is a bug that causes rather confusing behavior
regarding the use of api keys (or lack of it) in the current gateway firmware (v1.12.4) which is getting fixed in v1.13. This fix seem to includes some changes in the gateway configuration UI, so I'll update the RuuviBridge configuration docs once this release is live, I'll leave this issue open to track that

Until that fix on the gateway is released, there are two options for the "polling mode":

  • "the original way":
    • On the gw access settings page, choose "Remote configurable without password"
    • In RuuviBridge config: leave the bearer token blank (it must be blank with v1.12.4 firmware due to the mentioned gw bug)
  • "the current way" (recommended with v1.12.x and newer gateway firmware, will change slightly with v1.13)
    • On the gw access settings page, choose password protection of your choice, and from under Advanced settings enable bearer authentication and copy the key
    • In RuuviBridge config: enter the bearer token from the gateway config page

@TimVog
Copy link
Author

TimVog commented Oct 30, 2022

Thanks for the quick response and summarizing both options.

I stick with the second option and in hindsight, I know why it failed (but was successful with the browser). I still have the standard password protection on the gw, so it was no problem to access the history file by my broweser. But when I log-in to my server and try to download it with wget, it fails, since I don't use any verfication (I assumed only the setup process of the gw is password protected and not the history).

In the end, the API key solved all the problems and RuuviBridge is running great 👍

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

2 participants