openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

[homekit] "No response" error on all openHAB items #3522

Closed radokristof closed 5 years ago

radokristof commented 6 years ago

Dear Community and Developers!

I have been using the homekit addon now for months and I have a problem with it, which I found on the forum, most of us has this problem. Sometimes the whole Home becomes unavailable, all the items in the Home app shows "No response" message. I have tried to debug it, but I can't find any relevant info, openhab does not show any error or log message when this happens. Also it happens very randomly... Sometimes works for days, sometimes just for hours. The only solution is to restart openhab (but somehow it works after a while, no need to restart, but this can take hours).

Tell me how can I help to solve this bug!

Ways to reproduce the bug: Use the builtin HomeKit addon and enable on a device the Hub function.

Solution: It seems that the Hub feature causes this issue. Temporary fixes: Turn off the Hub Use the temporary workaround by @andrey-yantsen

Thanks!

andrey-yantsen commented 6 years ago

Same problem here. I've enabled TRACE-log on the binding couple days ago and those are last log messages related to homekit, before items become unavailable:

2018-05-06 00:24:22.839 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0
2018-05-06 00:24:22.840 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results
2018-05-06 00:24:22.840 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /192.168.88.67:49425
2018-05-06 00:25:12.016 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0
2018-05-06 00:25:12.017 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results
2018-05-06 00:25:12.017 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /192.168.88.68:52146
2018-05-06 00:27:34.333 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0
2018-05-06 00:27:34.333 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results
2018-05-06 00:27:34.334 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /192.168.88.66:52228

After this events those 3 clients can't communicate with HomeKit (unfortunately I don't have any more HomeKit clients available), but, unfortunately, I'm unable to confirm if communication dies always after those messages. 192.168.88.67 is my AppleTV with HomeKit hub.

BTW, @rkrisi. it's not required to restart entire OpenHab instance, for me it's enough to just to refresh homekit bundle via karaf console, just send following command:

bundle:refresh org.openhab.io.homekit

And after few seconds the items will return.

P.S. I'm using OpenHab 2.2-stable under Docker, on amd64 virtualbox VM, but the issue is annoys me since the time when I've used OpenHab 2.1-stable on Raspberry Pi 3.

andrey-yantsen commented 6 years ago

I've initiated a small bounty for this issue, feel free to join the club :)

andrey-yantsen commented 6 years ago

As for now I've created a workaround using python and mqtt to monitor amount of active homekit connections and refresh homekit bundle when last connection lost.

wborn commented 6 years ago

Thanks adding a bounty @andrey-yantsen! :smile:

radokristof commented 6 years ago

@andrey-yantsen Thanks, I'll try your method! Anyway, how can I change the logging level in openHab?

Now I don't know what about anyone's Home app, but sometimes it just shows that connected items not responding, but usually the openHab thing (or I don't know what it is called in Home app) and all other items are not responding...

andrey-yantsen commented 6 years ago

Anyway, how can I change the logging level in openHab?

For my workaround it's enough to use default INFO log level, but if you really want to change loglevel to TRACE for homekit bundle — just say log:set TRACE com.beowulfe.hap in your karaf console.

radokristof commented 6 years ago

@andrey-yantsen Thanks!

piejanssens commented 6 years ago

Ping @beowulfe

radokristof commented 6 years ago

My original post on the forum: https://community.openhab.org/t/homekit-no-response-on-all-openhab-items/43540

radokristof commented 6 years ago

I have tried logging and as @andrey-yantsen said, there is no real error message before the connection dies. It seems that it stops working after all the connections are lost to HomeKit devices. But why? Also we have 2 iPads which is connected to the HomeKit and always at home (one of them is the Hub), so I don't know why it sometimes loses connection and why does it stops working after losing connection.

piejanssens commented 6 years ago

This seems to be related to the fact that you are using a hub in your configuration. You could confirm this by removing the hub from the equation for a while and see if the issue still occurs.

andrey-yantsen commented 6 years ago

I'm not really sure if using a hub is the root if this issue: I'm also using a hub (Apple TV), but I can see in the logs that my phone connects directly to openhab instance. BTW, everything work correctly for almost 2 weeks now, even without my workaround.

radokristof commented 6 years ago

@piejanssens I don't think that Hub is the issue, since if you are at home, it connects directly to openHab... However now I'll try it without Hub. @andrey-yantsen Yes, I wanted to say the same until yesterday... it worked very well, without your workaround for a lot of days (haven't counted, but I noticed that it was a long time ago since I restarted the service). I don't know why this happens...

radokristof commented 6 years ago

Dear Everyone!

I have tried out using HomeKit with turned off Hub, and it didn't produced the "No Response" error. However I can't say that this is the cause of the error, because I had to restart the whole openHab several times due to that my smarthome is only in "beta", so lots of changes happens these times...

Secondly, 2 days ago I have updated openHab to the stable 2.3.0 release and I haven't experienced this issue (I have turned the Hub back on) and also some other issues were gone for me with this update. I will continue testing it and report it if I found out anything

aihysp commented 6 years ago

hi please tell me if the update did the trick... I will update also, for now I will stick with 2.2

radokristof commented 6 years ago

For me, 2.3 solved a lot of issue (and seems that this HomeKit error also)... However I saw on the forum that usually most people suffer from upgrading to 2.3 (think they already have a more complex OH setup than mine...)

radokristof commented 6 years ago

No it didn't solve it completely... It worked for much-much longer time than with 2.2, but now it is stuck again at "No response".

andrey-yantsen commented 6 years ago

I’ve disabled the hub a couple days ago, and everything is fine for now. Except for items which randomly loose rooms binding, but it may be happining only after items-file updates.

radokristof commented 6 years ago

@andrey-yantsen Thanks, I'll try again with Hub disabled... see if it is really changes anything Are you on 2.3 already?

andrey-yantsen commented 6 years ago

Yep

-- Andrey Yantsen Hotellook.com developer Tel.: +7-999-218-0373 Skype: andrey_janzen

On 3 Jun 2018, at 00:13, Kristof Rado notifications@github.com wrote:

@andrey-yantsen Thanks, I'll try again with Hub disabled... see if it is really changes anything Are you on 2.3 already?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

andrey-yantsen commented 6 years ago

I've re-enabled the hub back, because without it my items keep randomly disappear and lose rooms assignment :\ At list with hub issues I have a workaround.

radokristof commented 6 years ago

I still don't have much item exposed to HomeKit (2 item yet...), but I don't have this problem. For me it remembers every setting... However turning off Hub, solved the "No response" error, but it will be great that one time we could use the Hub feature...

andrey-yantsen commented 6 years ago

I have 54 items in HomeKit :)

-- Andrey Yantsen Hotellook.com developer Tel.: +7-999-218-0373 Skype: andrey_janzen

On 11 Jun 2018, at 20:35, Kristof Rado notifications@github.com wrote:

I still don't have much item exposed to HomeKit (2 item yet...), but I don't have this problem. For me it remembers every setting... However turning off Hub, solved the "No response" error, but it will be great that one time we could use the Hub feature...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

radokristof commented 6 years ago

@andrey-yantsen I just started this openHab and Home Automation thing a few months ago, but I will add a few new things during this summer. I will share my experencies after that :) Hope that HomeKit will receive an update with bugfixes and potentially new things in openHab (personally I really want shutters)!

codefalk commented 6 years ago

Just increased the bounty

kaikreuzer commented 6 years ago

@beowulfe Are you aware of this issue?

jscottnz commented 6 years ago

I have this problem too. I do not have a hub. I am on 2.2.

(Un)fortunately I have a 2 week vacation but I can look into this when I get back.

radokristof commented 6 years ago

@jscottnz first I think try updating to 2.3.0. As I said earlier, it is much better for me. As I remember on 2.2.0 I also tested without Hub and had the same problem as you. On 2.3.0 if you turn off Hub, it will work... however see @andrey-yantsen what he said, that his configuration loses the room assigments when it is turned off... I dont have this problem since I have a few items. Test you conf and post your results here!

andrey-yantsen commented 6 years ago

As for now the HomeKit works for 2 weeks with Hub enabled (apple tv). About the second issue, where items randomly loose room assignment, — it's not really so random and it's not related to Hub, it's just a new error introduces with 2.3.0, see #3687.

jj74 commented 6 years ago

I have the same issue. After using Homkit with OH 2.1 on an old Raspi 2, ive changed to an Raspi 3 (with an external SSD). First it worked fine for me, but suddenly homekit stopped working. It seems that its happening, when i disconnect (ant reconnect to) from my wifi. Then I have to restart a several times and sometimes the connectivity comes back again, but sometimes not. Then i have to delete the bridge and rebind it again, but that does not work anymore. Homekit on iOS says "couldn`t connect to openHAB".

Dan1001 commented 6 years ago

I have also failed to find a pattern in when homekit stops working. I thought it was linked to item updates, so I put all the homekit items in a separate items file, which I didn't touch. That didn't help - the homekit binding breaks every day or so anyway.

piejanssens commented 6 years ago

Possibly related to some of you: https://github.com/openhab/openhab2-addons/issues/1822

jj74 commented 6 years ago

Here`s an part of the error message from the log: 2018-07-11 08:32:36.192 [ERROR] [ulfe.hap.impl.pairing.PairingManager] - Exception encountered while processing pairing request com.nimbusds.srp6.SRP6Exception: Bad client credentials at com.beowulfe.hap.impl.pairing.HomekitSRP6ServerSession.step2(HomekitSRP6ServerSession.java:331) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.pairing.SrpHandler.step2(SrpHandler.java:76) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.pairing.SrpHandler.handle(SrpHandler.java:47) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.pairing.PairingManager.handle(PairingManager.java:44) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.connections.HttpSession.handlePairSetup(HttpSession.java:107) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.connections.HttpSession.handleRequest(HttpSession.java:51) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.connections.ConnectionImpl.doHandleRequest(ConnectionImpl.java:51) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.connections.ConnectionImpl.handleRequest(ConnectionImpl.java:46) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:47) [270:org.openhab.io.homekit:2.3.0] at com.beowulfe.hap.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:15) [270:org.openhab.io.homekit:2.3.0] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [270:org.openhab.io.homekit:2.3.0] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) [270:org.openhab.io.homekit:2.3.0] at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:32) [270:org.openhab.io.homekit:2.3.0] at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:299) [270:org.openhab.io.homekit:2.3.0] at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:36) [270:org.openhab.io.homekit:2.3.0] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [270:org.openhab.io.homekit:2.3.0] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [270:org.openhab.io.homekit:2.3.0] at java.lang.Thread.run(Thread.java:748) [?:?] 2018-07-11 08:32:36.196 [INFO ] [ap.impl.http.HomekitClientConnection] - 401 /pair-setup 2018-07-11 08:32:36.198 [TRACE] [pl.http.impl.NettyHomekitHttpService] - WRITE UnpooledUnsafeDirectByteBuf(ridx: 0, widx: 72, cap: 256) [/192.168.1.150:57901]: 00000000 48 54 54 50 2F 31 2E 31 20 34 30 31 20 55 6E 61 HTTP/1.1 401 Una 00000010 75 74 68 6F 72 69 7A 65 64 0D 0A 43 6F 6E 74 65 uthorized..Conte 00000020 6E 74 2D 4C 65 6E 67 74 68 3A 20 30 0D 0A 43 6F nt-Length: 0..Co 00000030 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 nnection: keep-a 00000040 6C 69 76 65 0D 0A 0D 0A live.... 2018-07-11 08:32:36.242 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /192.168.1.150:57901

Still not working/pairing after reboot.

Jesco

andrey-yantsen commented 6 years ago

@jj74 if it's not working after reboot — it's another problem.

jj74 commented 6 years ago

@andrey-yantsen is it? I think its exactly the same issue, as discribed above. Im also using an ATV4 as a hub. When I restart the Pi, the Homekit App cannot connect to OpnHAB (but shows it).

andrey-yantsen commented 6 years ago

@jj74 yep. Me and Kristof experience slightly different problem: Homekit works after restart, and no errors are visible in the logs. It would be quite strange if with the same problem and the same OpenHab version you suddenly would be able to get some error in logs, related to the same problem :)

radokristof commented 6 years ago

I haven't encountered an error in the previous weeks, but Hub is disabled for me now. @andrey-yantsen Interesting, but if I use openHab normally, restart it sometimes because of other things, my config didn't lose room associations (Now I have more switches than before, around 8-9). However if I refresh the binding with the command, it did lose every item and adds it to the 'Living Room'

aihysp commented 5 years ago

not sure if the issue is completely resolved, but for the last two weeks its been cool

sometimes items are NA but most of the time connected and even after a complete reboot of OH machine

also, I am not connected to the hub(Ipad Air 2) anymore i will connect it now and see if there is any difference

radokristof commented 5 years ago

@aihysp same for me, it is working fine for me now without hub, but if I enable the hub it stops working after a few hours

evelant commented 5 years ago

Same issue here. Homekit works well for awhile then stops until the binding is refreshed.

aihysp commented 5 years ago

@radokristof i have tested with Hub on for the last two weeks and even with OH reboots i dont get disconnected, on really rare times i see items as NA but most of the time working great!

Scorched81 commented 5 years ago

I'm also experiencing this issue of connection loss between openhab and my HomeKit hub (ATV4K). After reading here and enabling trace logging, all was good for days. Until tonight, when suddenly my connection was gone and all items showed no response. There was nothing out of the ordinary in the logs (other than what I've seen passing by for days), except for the following :

2018-09-11 21:40:39.726 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0 2018-09-11 21:40:39.735 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results 2018-09-11 21:40:39.741 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /10.0.0.30:60375 2018-09-11 21:41:23.094 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0 2018-09-11 21:41:23.098 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results 2018-09-11 21:41:23.101 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /10.0.0.32:50714 2018-09-11 21:41:30.747 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Received message of length 0. Existing buffer is 0 2018-09-11 21:41:30.752 [TRACE] [ons.LengthPrefixedByteArrayProcessor] - Returning 0 results 2018-09-11 21:41:30.756 [INFO ] [.hap.impl.http.impl.AccessoryHandler] - Terminated homekit connection from /10.0.0.40:49440 2018-09-11 21:41:48.279 [ERROR] [lfe.hap.impl.http.impl.BinaryHandler] - Exception in binary handler

Just to clarify, I'm really a beginner with this, so maybe it can help to investigate this problem further.

Edit : 10.0.0.3x Are my households iPhones; 10.0.0.40 is my ATV. It's seems to shutdown the connections one by one, and not reconnect them until openhab is restarted from cmdline.

radokristof commented 5 years ago

@aihysp Thanks for your contribution! What do you mean by NA? Are they seen as 'No Response'? I had few time the same thing (as I can remember I have mentioned here earlier) before, that I didn't had to refresh or restart openHab, it just came back after a few hours (maybe more than that...).

@Scorched81 Yes, I think you have the same issue as we... I don't have an ATV, but the device doesn't really seem to matter here. And yes, the restart is the best option I think. You can refresh just the binding (so you don't have to restart openHab) if you can login to the Karaf console, but for me it loses all the room association, so I have to set it back, one by one...

To be honest, I had bigger problems with my openHab setup in the last weeks, so I didn't had time to investigate this problem better... I have updated my iPad to iOS 12 a few weeks ago, I will try Hub with it. Now I'm using it without Hub and it works without a problem for me.

I'm on OH 2.4 Milestone build now

Scorched81 commented 5 years ago

@radokristof I just restart it with 'sudo systemctl restart openhab2.service' from command line in an SSH terminal. Never had it lose my room config though.

radokristof commented 5 years ago

@Scorched81 If my experiences right and you always restart it that way, you won't lose the room config

Scorched81 commented 5 years ago

Then I'll continue to do so ;). One thing came to mind, my troubles just recently started when I replaced my Pi 3B for a Pi 3B+ with POE HAT. All was running fine, until I noticed the fan was not spinning. After searching for the cause, it came clear that my OS was not up to date and had to be updated in order for the fan to be controlled. It was from this point forward that the troubles began. The previous config was running for over 80 days without a hitch. Maybe there is an incompatibility between the code of the OS update and the HomeKit binding ? (just thinking out loud though)

edit : typo

radokristof commented 5 years ago

I don’t think so. Are you using openHabian? I have used multiple configs, on multiple platforms and the problem is there. Most people here is using a server (usually x86 based PC) who has a bigger and more complex setup. I’m running mine on a RPi 3B (openHabian) and I use this RPi as well for my media center (Kodi). I don’t have much things in my setup, but it handles well (and I don’t even have active cooling on it as you)

On 2018. Sep 11., at 23:47, Scorched81 notifications@github.com wrote:

Then I'll continue to do so ;). One thing came to mind, my troubles just recently started when I replaced my Pi 3B for a Pi 3B+ with POE HAT. All was running fine, until I noticed the fan was not spinning. After searching for the cause, it cam clear that my OS was not up to date and had to be updated in order for the fan to be controlled. It was from this point forward that the troubles began. The previous config was running for over 80 days without a hitch. Maybe there is an incompatibility between the code of the OS update and the HomeKit binding ? (just thinking out loud though)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Scorched81 commented 5 years ago

Agreed, if it occurs on more than one platform, it's not an OS issue. I'm indeed running openhabian and have a mixed setup with HomeKit for light across the house (20something) as well as a thermostat. Also running other bindings as nest binding for nest protects and MQTT to control some Tasmota based Sonoff switches. So not terribly complex. I do however have multiple Pi's running their own dedicated tasks. The active cooling is more for the POE HAT, rather than cooling the CPU due to high loads.

radokristof commented 5 years ago

For me, it is working now perfectly on 2.4.0 M3 I have enabled Hub more than a week ago and I haven't had a single problem with it. My iDevices running iOS 12. I will keep testing it, but it seems that this problem is gone. Loading the switches through Hub takes some seconds now (it was more responsive before), but I can live with that. The No Response or 'N/A' thing never happened in the last week. Before this, it happened almost after a day or after 2 days.

aihysp commented 5 years ago

Hi @radokristof yes ,no response, what i mean is that before, when i reboot OH, i will need to do the paring again now after many reboots it pairs by itself when system boots

only issues i have is from time to time items have no response but its only for a few secs and then back