KraigM / homebridge-harmonyhub

HomeBridge Plugin for Logitech Harmony Hub
182 stars 52 forks source link

Home bridge won't start because of the HarmonyHub plugin #31

Open leoneleone opened 8 years ago

leoneleone commented 8 years ago

Hello,

only this past week homebridge stopped working and won't finish setup/initialise, the cause of which is the harmony hub plugin. Uninstalling the plugin and removing it from config.json was the only way I've found to fix the issue.

Any ideas?

r32er commented 7 years ago

can u tell me how this workaround works?

sommo commented 7 years ago

i can't find the link now, but i found i useful guide to get it work like a charm, when i found it i will post

sommo commented 7 years ago

founded: https://timleland.com/setup-homebridge-to-start-on-bootup/ follow this and you will get ok

r32er commented 7 years ago

and then home bridge restarts when it crashes because of harmony plugin?

sommo commented 7 years ago

yes, after you follow that steps, u will have homebridge running like a service, and it constantly check if it is running, if not it relaunch it. no matter what cause his stop, also it execute homebridge when rp reboots

r32er commented 7 years ago

hm seems to be Little tricky for me.

ccaramel commented 7 years ago

Got the same issue. I just changed the "name" of the platform "HarmonyHub" in config.json and restarted homebridge. I worked again.

r32er commented 7 years ago

I tried to rename the platform but it still crashes with the same error again.... that sucks so hard. the only reason why i bought the harmony hub was the Siri support with home bridge. when this not work i will have to sent the hub back....

RienduPre commented 7 years ago

I installed the plugin on a new installed Homebridge on a RPi and it crashes within half an hour constantly. I'm running 2 hubs with the latest firmware.

If so many people are having this issue, why isn't being solved?

PashCracken commented 7 years ago

I have almost given up on this plugin. Yesterday I did some research and found that other harmony applications also have the same issue. So my understand of this issue now is that the MAX_CLIENTS=6 error actually originates from the Harmony Hub itself. The problem is that the client libraries/apps don't handle this error in a graceful way. They need to catch the exception and retry the operation.

r32er commented 7 years ago

What do you mean with other harmony applications?

PashCracken commented 7 years ago

I found this one from 2014: http://forum.micasaverde.com/index.php/topic,14928.msg167757.html?PHPSESSID=302dsv368aajtf036l3ig21sk2#msg167757

And also this one that states that this is an error from the hub itself https://forum.athom.com/discussion/653/submitted-for-approval-harmony-hub-app-v0-3-4/p14

If this is correct then this can be fixed by adding some error handling in the plugin or in one of the libraries used for communication with the hub

RienduPre commented 7 years ago

Now it's crashing every 2 minutes :-(

Please solve this issue

leoneleone commented 7 years ago

Has anyone who's complaining of these problems tried updating NodeJs 7.x and updating Homebridge to its latest iteration?

leoneleone commented 7 years ago

While I agree the plugin could use some error handling, everything seems to working fine for me. I've recently had to reset my HomeKit config. Everything still working fine after I re-added homebridge with quite a few plugins

PashCracken commented 7 years ago

I run it on a Raspberry Pi. In my latest attempt to see if it was stable I updated everything to the latest version. Still the same error

leoneleone commented 7 years ago

@PashCracken What version of node are you running?

kenderson commented 7 years ago

Just wanted to throw my 2 cents in here. I am running into the same error that everyone else seems to be hitting. "Error: MAX_CLIENTS=6"

My set-up is;

Let me know if any additional information is needed! Thank You!

leoneleone commented 7 years ago

@kenderson Can you try upgrading Node to 7.x version?

kenderson commented 7 years ago

@leoneleone Done. I'm now on 7.2.1. I'm now getting the following error. Unhandled rejection Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: XXXXXX-XXX-XXX

A few data points;

Any thoughts/guidance is greatly appreciated! Ken

cyberb0b commented 7 years ago

@kenderson - stop homebridge, remove the content of the persist folder.

kenderson commented 7 years ago

@cyberb0b Thanks for the assist here. QQ before I do that - will that require me to re-add the bridge to homekit and reconfigure all of the accessories and automations that are in place?

Thanks Again!

cyberb0b commented 7 years ago

@kenderson if your hub is still in the config, just start homebridge.

Settings of automations are not stored inside homebridge, only in the homekit db from Apple.

leoneleone commented 7 years ago

@kenderson The advice from others above is sound. My suggest is to:

  1. remove homebridge from HomeKit
  2. Delete .homebridge/accessories & .homebridge/persist folders.
  3. Reboot homebridge

It is true you will lose all accessory sorting (into rooms, service groups, and automations) and association, but it is an easy thing to rectify.

Please let us know if that has solved the problem for you. Otherwise maybe we could try adding some error handling code to the plugin.

IceCreamGuys commented 7 years ago

I have to do this every other day to keep mine running. It works, but it is temporary.

On Dec 23, 2016, at 10:33 AM, leoneleone notifications@github.com<mailto:notifications@github.com> wrote:

@kendersonhttps://github.com/kenderson The advice from others above is sound. My suggest is to:

  1. remove homebridge from HomeKit
  2. Delete .homebridge/accessories & .homebridge/persist folders.
  3. Reboot homebridge

It is true you will lose all accessory sorting (into rooms, service groups, and automations) and association, but it is an easy thing to rectify.

Please let us know if that has solved the problem for you. Otherwise maybe we could try adding some error handling code to the plugin.

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/KraigM/homebridge-harmonyhub/issues/31#issuecomment-269022190, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AV0gYggDfeCacf741C0ZzobAPMky6hsWks5rLAXigaJpZM4IRtU4.

cyberb0b commented 7 years ago

I have installed it as a service, so every time it crashes it recovers. But what am i wondering about, the persons with error max client 6, do they all have more than 1 harmony hub?

IceCreamGuys commented 7 years ago

I have three hubs running

On Dec 23, 2016, at 10:36 AM, cyberb0b notifications@github.com<mailto:notifications@github.com> wrote:

I have installed it as a service, so every time it crashes it recovers. But what am i wondering about, the persons with error max client 6, do they all have more than 1 harmony hub?

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/KraigM/homebridge-harmonyhub/issues/31#issuecomment-269022544, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AV0gYuU0Xq1WnY27OefFElp-SrnJ6-Wpks5rLAaNgaJpZM4IRtU4.

PashCracken commented 7 years ago

It turns out I was running node version 5.2. I've upgraded to version 7.3 now. Will report back after some testing

cyberb0b commented 7 years ago

New node version is probably not gonna work, if I check out hub-connection.js I see no error handling for code 6.

neilgupta commented 7 years ago

It has nothing to do with number of hubs running. The problem is that the underlying harmonyhubjs-discover library keeps making multiple connections to the hub, which has an internal hard-coded limit of 6 max connections. This is why other projects are also facing this problem. The best fix is for the lower-level library to fix its leak so it manages a persistent connection, but this project could also be smarter about how it creates new connections.

Try out the following code in node's console:

var HarmonyHubDiscover = require('./node_modules/harmonyhubjs-discover');
var discover = new HarmonyHubDiscover(61991);
var hubInfo;
discover.on('online', function(hub) { hubInfo = hub });
discover.start();
var Connection = require('./lib/hub-connection');
console.debug = console.log;
var c = new Connection(hubInfo, console, discover);
c.connectAsync(hubInfo);  // run 6 times and it'll emit the same error (but not crash because it's caught)

Somewhere in homebridge-harmonyhub, the max connection error is going uncaught or getting rethrown. I only have one hub with one activity, so number of hubs makes no difference.

The frustrating part is how intermittent/random the problem is. It's difficult to figure out reproduction steps. I tried running Homebridge in debug mode to gather more logs a couple weeks ago, but haven't seen it crash since then... For a few weeks before that, it was crashing daily.

I haven't tried this myself yet, but running homebridge as a service to auto-restart when it crashes is probably your best bet for now if you're seeing this error.

cyberb0b commented 7 years ago

Stupid suggestion maybe, but why not put error 6 behind the timeout?

I mean, like in hub-connection.js, var connection status 6.. and send it to the conntask timeout?

Those connections should timeout eventually I guess.

kenderson commented 7 years ago

@cyberb0b I removed content from both folders and fired everything back up. Now I get the following.

[12/23/2016, 1:06:05 PM] [homebridge-harmonyhub.HarmonyHub] Ignoring Harmony Platform setup because it is not configured

Thoughts?

sleepyarmistice commented 7 years ago

Your config file doesn’t have the info about the harmony platform in it.

On Dec 23, 2016, at 1:09 PM, Ken Henderson notifications@github.com wrote:

@cyberb0b https://github.com/cyberb0b I removed content from both folders and fired everything back up. Now I get the following.

[12/23/2016, 1:06:05 PM] [homebridge-harmonyhub.HarmonyHub] Ignoring Harmony Platform setup because it is not configured

Thoughts?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KraigM/homebridge-harmonyhub/issues/31#issuecomment-269026407, or mute the thread https://github.com/notifications/unsubscribe-auth/AQLd5wGrSf2T3_Ln_Mt5BUBVNMa4HaY9ks5rLA5PgaJpZM4IRtU4.

r32er commented 7 years ago

the same error i got when i started home bridge with the command: sudo homebridge. when i type only homebridge the it works for a while and runs into the max client error...

i upgraded to node 7.2.1 and now homebridge don't work ...

pi@raspberrypi:~ $ homebridge /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/lib/dns_sd.js:35 throw ex; ^

Error: The module '/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/build/Release/dns_sd_bindings.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 46. This version of Node.js requires NODE_MODULE_VERSION 51. Please try re-compiling or re-installing the module (for instance, using npm rebuild ornpm install). at Object.Module._extensions..node (module.js:598:18) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/lib/dns_sd.js:24:20) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32)

what is now wrong?

kenderson commented 7 years ago

@leoneleone @cyberb0b & @sleepyarmistice - Thanks for the assistance from you all! So below are a few data points;

Below is a breakdown of the what it took for me;

kenderson commented 7 years ago

@leoneleone @cyberb0b & @sleepyarmistice - I spoke too soon. I just got the Max Clients error. I got about 2 hrs out of it beforeI hit the error.

At this point, I have to agree that this really needs better error handling within the plugin.

Let me know if there's anything else I can help try/test.

Thanks Again! Ken

r32er commented 7 years ago

@kenderson Can you tell me why my homebridge doesnt work since I update node to 7.2.1?

I really give up with the harmony plugin. But now even the hole homebridge doesn't work...:/

kenderson commented 7 years ago

@r32er When I first updated, I got the same error you did. I had to uninstall and reinstall homebridge and all plugins. I'm guessing when you install them there's a reference to the node version. So you're probably seeing an error b/c they're looking for the previous version of node.

r32er commented 7 years ago

Can u tell me how it works ? I m really a noob with this...

kenderson commented 7 years ago

@r32er no problem. Are you looking for guidance on how to uninstall and reinstall? Or a deeper understanding of the issue? I can help you with the uninstall and and reinstall commands....but probably not with a deeper understanding. Let me know!

r32er commented 7 years ago

Only the uninstall re install so homebridge will work again please.

kenderson commented 7 years ago

@r32er No problem. My routine was;

Repeat the last two for all plugins Let me know if you have any additional questions. Ken

r32er commented 7 years ago

thank you ! i will try this. This ist everything? its easier as i thought

Update: I got this error.. pi@raspberrypi:~ $ sudo npm uninstall -g homebridge module.js:472 throw err; ^

Error: Cannot find module 'internal/fs' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at evalmachine.:17:20 at Object. (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/graceful-fs/fs.js:11:1) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) pi@raspberrypi:~ $

BananimusPrime commented 7 years ago

Hi, I've started experiencing this issue over the last few weeks. I'm using Node v7.4.0, and have tried @kenderson 's example of updating Node, then uninstalling and reinstalling homebridge and its plugins, but after a short period of time the same error occured, max_clients=6.

starlessblack commented 7 years ago

I've had good luck downgrading to the previous HarmonyHub plugging version. It never crashes out my homebridge install.

BananimusPrime commented 7 years ago

Thanks for the advice @starlessblack , can I please ask how I downgrade a plugin? Thanks

starlessblack commented 7 years ago

Sure--essentially, I followed this person's advice: https://github.com/KraigM/homebridge-harmonyhub/issues/61#issuecomment-261899772

Uninstall the current version of the plugin, download the old one, unzip it, run the "sudo npm install –g" command from that directory to install it...I think that's about it. Mine's now been running for close to a month without any crashes.

mrdavidsilva commented 7 years ago

Are you able to use multiple hubs after downgrading?

starlessblack commented 7 years ago

Oh, I'm not sure, as I only use a single hub. If that was a feature of the newer version of the plugin, then this option might not work for you. It looks like the developer alludes to using a workaround in the old version, adding multiple platforms to the config file. Maybe it'll still work for you after all.

grahamr commented 7 years ago

When I first ran my setup I had two hubs in my config file - unless an update on the harmony end fixed something I had the crashing more than with the .20 builds.

From research it looks like the issue lies with the error handling in the library used by the plugin - the amazon echo and smart things plugins are the same issue.

On Feb 21, 2017, 10:58 AM -0400, starlessblack notifications@github.com, wrote:

Oh, I'm not sure, as I only use a single hub. If that was a feature of the newer version of the plugin, then this option might not work for you. It looks like the developer alludes to using a workaround in the old version, adding multiple platforms to the config file. Maybe it'll still work for you after all.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/KraigM/homebridge-harmonyhub/issues/31#issuecomment-281368017), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAFB5Ve9D34kk_ZswYeh-P-TM41a9a_Vks5revuvgaJpZM4IRtU4).