apple / HomeKitADK

Apache License 2.0
2.55k stars 232 forks source link

The HomeApp auto disconnect #132

Closed Suphappy closed 1 year ago

Suphappy commented 1 year ago

When my iPhone locks the screen for a while, reopening the HomeApp breaks the TCP connection and will never actively connect to the device (Linux platform) again unless I run the device again. The following logs are generated when the connection is disconnected.

2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Event notification timer expired. 2023-04-30'T'14:31:59'Z' Info [com.apple.mfi.HomeKit.Core:Characteristic] [0000000000000004 testname] [0000000000000037 on] Calling read handler. 2023-04-30'T'14:31:59'Z' Info Light_ReadOnoff: on 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:< 0000 4556454e 542f312e 30203230 30204f4b 0d0a436f 6e74656e 742d5479 70653a20 EVENT/1.0 200 OK..Content-Type: 0020 6170706c 69636174 696f6e2f 6861702b 6a736f6e 0d0a436f 6e74656e 742d4c65 application/hap+json..Content-Le 0040 6e677468 3a203530 0d0a0d0a 7b226368 61726163 74657269 73746963 73223a5b ngth: 50....{"characteristics":[ 0060 7b226169 64223a34 2c226969 64223a35 352c2276 616c7565 223a317d 5d7d {"aid":4,"iid":55,"value":1}]} 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:input closed 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:closing 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:closing security context 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Closing HAP session. 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:Session] HAPSessionRelease 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:Session] HAPSessionInvalidate 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:closing TCP stream 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Platform:TCPStreamManager] shutdown(13, SHUT_RDWR); 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Platform:TCPStreamManager] close(13); 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:closed 2023-04-30'T'14:31:59'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4b1eb0:releasing session

Suphappy commented 1 year ago

When I looked at the thread with the "strace" command, I saw that the loop task was blocked forever:

strace strace: Process 259064 attached select(14, [5 7 9 13], [], [], NULL