Open terracotta004 opened 6 years ago
ah, that's a really ugly message.
I just tried this manually and am able to reproduce it. If a server is running on port 80 that is not hue, the hue.js library hue-cli
uses unfortunately will not trigger an error. If you look at that repo it's painfully out of date, and I even have a PR that was never addressed.
Instead, I'd recommend you take a look at huadm. This is the spiritual successor to hue-cli
with far more options and robust error handling. Running the same test on hueadm
, first using a host not running a server on port 80, and second using a host running a file server on port 80, has the following results.
$ ./bin/hueadm -H 10.0.1.1 -U foo lights
error: Error: connect ECONNREFUSED 10.0.1.1:80
$ ./bin/hueadm -H localhost -U foo lights
error: Error: bad statusCode 404
Recently I was running into this bizarre error whenever I ran anything to do with
hue lights
(e.g.hue lights on
,hue lights off
, etc.) on node v9.3.0, npm 5.6.0, & hue-cli 0.3.1.I was about to ask for help here, but then I realized that the IP of my hue bridge changed, which may or may not have been the root of the problem. After re-registering hue-cli with the new configuration everything started working again. However, this original error message was pretty unhelpful in indicating that this might have been the problem. It could have been that the old IP was given to a different device on the local network and hue-cli was getting bogus data from it.
I'd suggest that this part of the code be adjusted so that, if the configuration stops working for some reason, it gives a more helpful error message stating something has changed with the connection, instead of leaving the user to scratch their head in confusion.