-
Notifications
You must be signed in to change notification settings - Fork 145
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
Discovery and bridge access fail with 501 when using a HTTP proxy #171
Comments
Here's the response:
with HTML error page:
|
axios is just broken:
But as explained, even if the HTTP proxy request would work, it would still be wrong to use the proxy. |
Fixed in PR #173 |
Thanks for all the details and hard work on this. The only scenario that I can think of currently that needs to be accessed here is the remote API use of this library. In this case you will be establishing a connection to the internet as it is the Remote API in the cloud provided by meethue.com. I have been considering the removal of axios as it is starting to pull in more library dependencies that are just not necessary for this API. I have the beginnings of this work as an experiment in a branch that might make sense to complete and just remove axios altogether. Do you have the ability to test the remote API usage with your code changes? I don't have a proxy set up currently to test with, but can probably get to validating this later in the week when I get some time to configure one for testing. |
Yes, I was thinking of that. See Expected result point 3. But... How is the Hue bridge connecting to meethue.com ? I don't think it can use a proxy, does it? So, we already know for sure that the connection to meethue.com is possible without proxy. At least from the same network as the Hue bridge is on. That leaves only the case where 1) I control the lights in my house from somewhere outside of my house and 2) that other place requires a proxy to connect to the Internet. I don't think there are going to be many places where both of this is true at the same time. Theorectically possible, yes, but rather unlikely. The problem is that, right now, all users with a proxy are failing. Even if they are at home where the Hue lights are, and even if the proxy is optional. It's failing 100% of the time when a proxy environment variable is defined, as far as I could discern. Even if the proxy is working perfectly fine, it's still failing. My proxy is for privacy purposes, and if I connect directly (from Hue hub) and via proxy (from this API) to the same account, Philips can connect the two IP addresses, which is exactly what I don't want. |
The good news is that the old code failed 100% of the time, so you can't actually break much :) |
Unfortunately I have to validate all the usage scenarios, so in the use case you have, yes, entirely, I understand the failure. Unfortunately there are other usage scenarios like the remote API access (api.meethue.com) and usage inthe browser that I need to validate this all against before merging into the release branches. I will set up a simple proxy later this week to run my test suites against. Once again, thank you for the contribution and bringing this to my attention 😄 |
Is this a complete blocker for you currently, as you have a work around (as per the PR that you submitted)? Just asking so that I can prioritise things properly. |
This was completely preventing me from using the lib. |
You are the first to have reported this, hence I don't think it is that common in practice (or there are a lot of quiet people out there facing it, but not reporting it anywhere). I am looking at the possibility of removing axios with a fetch based versions for the http communications, as axios has grown in size and dependencies it has pulled in. The use case of this library for users covers more than just Node.js server side usage, I have a number of users the embed it in the browser, which has a number of complications as well. It is taking me much longer than I would have liked to review the impact of the changes you have provided to mutliple environments (as well as having to set up proxying servers to test all of this). As long as you have a solution for now, I will take some time to review all the possible implications and solutions available here. |
Hi @benbucksch 👋 , I have just built up a branch with passing tests and the Are you in a position to test the I have some further testing to do on this for the remote and browser use cases but after that and your confirmation that it works for you, it will be published as a release. |
Hi! I have the same issue as @benbucksch, especially when trying to connect to a local bridge but through an http proxy. I didn't find a way to make it work using the 4.0.9 release, but I switched to the If anyone else stumble across this issue, here is a quick proxy setup: require('global-agent').bootstrap();
global.GLOBAL_AGENT.HTTP_PROXY = 'http://127.0.0.1:1080'; // can also use environment variable
const host = '192.168.1.XXX'; // has to be your bridge's ip
const user = 'XXX'; // and your user key
require('node-hue-api').v3.api.createLocal(host).connect(user).then((api) => {
api.lights.getAll().then(lights => console.log(`found ${lights.length} lights!`));
}); node test.js
found 11 lights! 🎉 |
Thanks, I will be cutting a new 5.x release soon with this fix in it |
Reproduction
https_proxy=myproxy:1234
, whereas myproxy:1234 is a Squid proxy. This is a global user config, applying to the entire user session, set e.g. (among others) by the GNOME settings tool for the GNOME browser.hue.discovery.nupnpSearch();
hue.api.createLocal(hueBridgeLocalIPAddress).connect();
Actual result
Both calls (step 2 and step 3) return with error message:
CONNECT
command is required, but it's not used, leading to the error.Expected result
It's better to completely un-support and ignore proxies than doing an invalid request that will fail.
In short: Don't use the HTTP proxy at all. It makes no sense for this API.
The text was updated successfully, but these errors were encountered: