Homekit stops working after some hours. openhab 3.4.0

@apas_csc @gd35 @StefanH

If you are struggling to get it working with SSH as I described here
There is a second possibility using sshpass to restart Homekit on regulary basis:

  1. install sshpass in your openHAB
    Open a bash to your openHAB and install sshpass:

    apt-get update
    apt-get upgrade
    apt-get install sshpass
    

    If you use docker: open terminal → “start with command” → type in “bash” → hit return

  2. create rule

    rule "Homekit Bundle restart"
    when 
       Time cron "0 0 8 1/1 * ? *"  or  // daily 08:00h 
       Time cron "0 0 16 1/1 * ? *"     // daily 16:00h  
    then
       logInfo("Homekit", "Homekit-Bundle-Restart")
       executeCommandLine(Duration.ofSeconds(6), "sshpass", "-p", "habopen", "ssh", "-oStrictHostKeyChecking=no", "-oUserKnownHostsFile=/dev/null", "-p8101", "openhab@localhost", "bundle:restart", "org.openhab.io.homekit")
    end
    

.
When rule is executed you should see in the log:

[INFO ] [rg.openhab.core.model.script.Homekit] - Homekit-Bundle-Restart
[INFO ] [mekit.internal.HomekitChangeListener] - Created x HomeKit items in instance 1 (no change from prior configuration).

I tested this on my OH3.x and OH4.x - and it is working well.
All my problems with missing connection(s) to HomeKit are gone.

Let me know, if that works for you :slight_smile:

Best, Kai

I run the restart three times a day and sometimes even this is not enough. We need a fix rather than work around :frowning:

After one month, I had not a single disconnect. The code seems to react on the many changes on IPv6 addresses due to privacy extensions, causing the race condition described by @yfre more frequently.

Running my NAS on IPv4 only is acceptable for now, but in the long run I’d rather see the issue fixed. Either the code should react only on changes for the bound address, whether it is IPv4 or v6, and ignore other addresses or, ideally, the race condition should be fixed or mitigated.

@StefanH @apas_csc
the issue is pretty tricky and is difficult to reproduce and to fix.

i think, @ccutrer has the best explanation for it

with regards to ipv6 changes. in the past, homekit was listening to only one ip address and ignoring all other. but there was a valid use case with changes on multiple interfaces, so, i have added this functionality… probably, i need to make it configurable, e.g. if IP address provided, listen only to it, otherwise to all interfaces.

1 Like

I tried to disable IPv6 in the openHAB network configuration and enable “use openHAB mDNS service” for HomeKit. But then it will still print things like

removed interface /fd12:5b1f:da6e:e54c:211:32ff:fe75:ce6c%eth0

every couple of hours. So I go back to disabling IPv6 completely on my host.

Thank would explain a lot!