hap-java / HAP-Java

Java implementation of the HomeKit Accessory Protocol
MIT License
153 stars 82 forks source link

possible concurrency issue #27

Closed nathanjskelton closed 5 years ago

nathanjskelton commented 7 years ago

When I am running with multiple HomekitServer/HomekitBridge's on multiple ports, I am getting the following exception randomly (maybe once per day at random times) causing one or more of the bridges to stop responding.

When I had everything in a single bridge, I had no problems at all. The reason for multiple bridges is to isolate "experimental" accessories from the 60 "working" accessories that I have to prevent corruption in the "working" bridge causing me to have to re-add everything to HomeKit when an "experimental" accessory corrupts the bridge.

Fri Nov 25 01:28:52 EST 2016 WARNING: Responder(ubuntu01.local.)run() exception java.io.IOException: Operation not permitted at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:693) at javax.jmdns.impl.JmDNSImpl.send(JmDNSImpl.java:1536) at javax.jmdns.impl.tasks.Responder.run(Responder.java:148) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) CLASS: javax.jmdns.impl.tasks.Responder run Fri Nov 25 01:28:56 EST 2016 INFO: Terminated homekit connection from /192.168.1.33:53034 CLASS: com.beowulfe.hap.impl.http.impl.AccessoryHandler channelInactive

This also happens sometimes when the server is starting up, but it seems to recover from it then with a: "WARNING: ubuntu01.local.recover() We are back! CLASS: javax.jmdns.impl.JmDNSImpl __recover"

It appears that perhaps something is not thread safe, but it's tough to isolate what from the trace. Any insight appreciated.

hpposch commented 6 years ago

I also noticed that when I start a new Server with a Bridge inside a new Thread (not main Thread), my iPhone sees the Bridge inside the Home app, but I am not able to successfully connect. When I execute the same code in the main Thread everything works fine!

So here must be some problem. I am trying to debug the process, maybe I can give you some information about that.

timcharper commented 5 years ago

Closed for inactivity