Homekit not working properly

same with OH2.2 build:

And it is 100% related to iOS device leaving wifi/ losing network connectivity.

2017-12-20 13:09:26.400 [ERROR] [lfe.hap.impl.http.impl.BinaryHandler] - Exception in binary handler
java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) [?:?]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:192) [?:?]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) [?:?]
	at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:447) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:880) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [213:org.openhab.io.homekit:2.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2017-12-20 13:09:26.409 [ERROR] [.hap.impl.http.impl.AccessoryHandler] - Exception caught in web handler
java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) [?:?]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:192) [?:?]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) [?:?]
	at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:447) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:880) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [213:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [213:org.openhab.io.homekit:2.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]

I have been noticing this again as well now that Iā€™m on 2.2.

Hi,

Just started getting these errors as well, do we know if its fixable/avoidable?

2018-01-04 11:25:51.755 [ERROR] [lfe.hap.impl.http.impl.BinaryHandler] - Exception in binary handler
java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) [?:?]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:192) [?:?]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) [?:?]
	at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:447) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:880) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [224:org.openhab.io.homekit:2.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2018-01-04 11:25:51.762 [ERROR] [.hap.impl.http.impl.AccessoryHandler] - Exception caught in web handler
java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) [?:?]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [?:?]
	at sun.nio.ch.IOUtil.read(IOUtil.java:192) [?:?]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) [?:?]
	at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:447) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:880) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [224:org.openhab.io.homekit:2.2.0]
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [224:org.openhab.io.homekit:2.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:?]

OH2.2 as well

I have exactly the same problem.
@beowulfe Will there be a solution for this problem?

Same for me.

Iā€™ll see if I can repro this - seems like it should be easy to.

2 Likes

Many thanks Andy. Let me know if you need more Information to track this.

I have this same issue. Please just let me know if I can supply any logs or anything else to help resolve this issue.

Thanks

As I reported earlier in this thread, these exceptions are harmless and theyā€™re just the result of an iOS device timing out or leaving the wifi network or losing connection some other way. They just clutter the log.

The exceptions have been fixed in the HAP-Java repository since August 2016, but OH has not gotten an updateā€¦ probably because of the indecision on semantic tagging?

Is anyone actually seeing any negative effects on functionality because of these exceptions? Everything works fine for me. The fix in holgerebertā€™s comment here to make the HomeKit JSON DB non-writable stopped any problems with reboots as well (so far):

https://github.com/openhab/openhab2-addons/issues/1822#issuecomment-329693734

nope. same here.
just a simple timeout error (could be changed to Warn level maybe?) being logged when the iPhone goes offline.
Functionality is not affected when iPhone is back online. Homekit works properly (on openHAB 2.3.0 Build #1178)

After this exception the HomeKit is not connected anymore to my OH 2.2.
In iOS Home App I get all devices listed as not reachable.
The only way I found to solve this problem is to clear the pairings and connect again.

I also had issues with Homekit connectivity. I could not connect to devices returning home especially when I tried to connect to them when I was away from home with the ā€˜Homeā€™ app.
I got a Philips Hue set a while back (3 lamps and a bridge) and since the homekit has been rock solid. Not a single issue in over a month in connectivity. When I added the Hue set i was also able to add my girlfriends phone (different icloud account). Previously the invitations gave an error. When I added the Hue suddenly the queued invitations were all send out.

Maybe someone with a Hue set can confirm this.
Could not be happier with the OpenHab setup as my domotica does not support Siri natively.

Same problem here! Nothing working until i restart my raspberry ā€¦

These exceptions show up in my logs too. Everything seems to work just fine. But really donā€™t like all this log cluttering .

If i understand @anthonygillet this was fixed 1,5 years ago but itā€™s not yet in openHAB. Maybe @beowulfe could look into this?

The semantic tagging topic for openHAB is getting nasty slow (2 years!) and long, so maybe these fixes can be implemented before that discussion is solved, if it ever gets solved?! Iā€™m happy to test or support in anyway i can. I just lack the knowledge to make a PR.

Hereā€™s the commit in HAP-Java, it changes the exceptions to debug level if itā€™s an IOException.

I think thereā€™s already an issue on github to get this library updated from 1.1.3 to 1.1.4 (or even 1.1.5) in the homekit add-on, which would solve this and a few other issues like the startupTimeout fix! Looks like there is a beta version linked there:

@beowulfe do you need more feedback about the beta version before pushing it to master? Perhaps a few of us here can test if you need. Otherwise, whatā€™s the next step for getting this updated?

Correct - the beta version of the HomeKit add-on used the newer version of the HAP-Java library. Please do try it out and let me know. I havenā€™t heard much feedback, and the changes to startup in that beta are significant.

This version?


I will download it and do some testing. Anything in particular you want feedback on?

Is there any way to just turn off this log messages?

there is. you can manually configure, what to log.
see here:

i did this and it worked great

How does your configuration look like?

Mine is the following, but it doesnā€™t work:

log4j2.appender.event.filter.floodstop.type = RegexFilter
log4j2.appender.event.filter.floodstop.regex = .*(Exception in binary handler|Exception caught in web handler).*
log4j2.appender.event.filter.floodstop.onMatch = DENY
log4j2.appender.event.filter.floodstop.onMisMatch = ACCEPT