question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discovery and bridge access fail with 501 when using a HTTP proxy

See original GitHub issue

Reproduction

  1. Set environment variable 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.
  2. Run hue.discovery.nupnpSearch();
  3. Manually configure the bridge IP address and run hue.api.createLocal(hueBridgeLocalIPAddress).connect();

Actual result

Both calls (step 2 and step 3) return with error message:

Request failed with status code 501
  1. The HTTP proxy is used for contacting the local Hue bridge. That is likely to fail.
  2. The HTTP proxy request used is invalid. The protocol implementation is incorrect. This is a TLS request, so the HTTP CONNECT command is required, but it’s not used, leading to the error.

Expected result

  1. If you want to use HTTPS or TLS request via HTTP proxy, the HTTP CONNECT protocol is required.
  2. The HTTP proxy is not used for contacting the Hue bridge, because the bridge is local. The HTTP proxy is for the Internet.
  3. It may be helpful to use the HTTP proxy for contacting the discovery.meethue.com server, but given that the Hue bridge contacts the server without proxy, it’s actually more privacy-preserving not to use the proxy, to avoid that the Hue server can associate the proxy IP address and real IP address. So, even in this case, I recommend to ignore the HTTP proxy.

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
peter-murraycommented, Dec 8, 2020

Thanks, I will be cutting a new 5.x release soon with this fix in it

0reactions
jclerccommented, Dec 3, 2020

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 main branch instead and used global-agent as well, it does now work!

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!

🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the HTTP 501 Not Implemented Error on Your Site
The HTTP 501 Not Implemented status code indicates that the server does not support the functionality required to fulfill the request.
Read more >
Aruba 501 Wireless Bridge stopped working? | Wireless Access
Help needed with Aruba Web-CC / PEF on Conductor/Controller setup ... Is it possible to discover Aruba Access Points (IAP) in virtual controller,...
Read more >
Discovery or metric collection failed - ITOM Practitioner Portal - Micro ...
Cause 1. The AWS collector is unable to reach the target AWS account if you haven't configured a proxy or configured a wrong...
Read more >
How to Fix the HTTP Error Code 501 - Elegant Themes
What Can You Do About a 501 Error? · 1. Reload The Page · 2. Clear Your Browser Cache · 3. Check Your...
Read more >
HTTP-Proxy: Exceptions - WatchGuard Technologies
Request headers and response headers are parsed by the HTTP-proxy even when the traffic matches the HTTP-proxy exception. If a parsing error does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found