Bouke / HAP

Swift implementation of the Homekit Accessory Protocol
https://boukehaarsma.nl/HAP/
MIT License
364 stars 50 forks source link

NIO Precondition fails on first pairing #90

Closed JulioBBL closed 5 years ago

JulioBBL commented 5 years ago

I am trying to pair with the home app, but i am facing a little snag. Just finished following the steps to build the project on my mac, created an xcode project for debugging, this is what happens when i run hap-server

➜  hap-server git:(master) ✗ swift run hap-server
'CLibSodium' /Users/btg/Documents/GitHub/HAP/.build/checkouts/CLibSodium: warning: system packages are deprecated; use system library targets instead
[hap.device|ERROR] Error reading configuration data: ENOENT, using default configuration instead
[hap.http|DEBUG] binding listening port...
[hap.http|DEBUG] bound, listening on 8000
Initializing the server...

Scan the following QR code using your iPhone to pair this device:

▄▄▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄▄▄
█ ▄▄▄ █ ██ █▄ █ ▄▄▄ █
█ ███ █ ▄ ███ █ ███ █
█▄▄▄▄▄█ ▄ ▄▀█ █▄▄▄▄▄█
▄  ▄▄▄▄▄▄▄  ▀▄  ▄ ▄▄▄
  ▄▀▄▄▄█ ▀█ ▄▄▀█▀█▀▄▄
▀ ▀█▀▄▄ ▄▀ ▄ █▀▄▄█▀▀▀
▄▄▄▄▄▄▄ █ ▀▄▄ █▄▄█▀ ▀
█ ▄▄▄ █ ██▄▄▀▄█▄█▀   
█ ███ █ ▀▄▀▄███▀▄▀▄▄▄
█▄▄▄▄▄█ ▄ ▄█▀▀▀  █ █ 

i take my phone out, point to the screen.

[hap.nio|INFO] Controller [IPv6]::ffff:10.11.175.194/::ffff:10.11.175.194:60975 connected, 1 controllers total
[hap.device|INFO] State change from: notPaired to pairing
[hap.controllers.pair-setup|INFO] Pair setup started
[hap.controllers.pair-setup|DEBUG] <-- s bf2affeee21fe81523abbd824161c8bf
[hap.controllers.pair-setup|DEBUG] <-- B f09a3b04b742df5cdb6ace0dbae1b5b94d2d3f3e97bedaccb63511b0720cd1186e852bd6301701f112fcf9190a36cae440df89281551ce24d4fbba900df0766e483f05e5b0d1ab709946860aa6ec8b534e85f038bf20ecfb027ce550def8ff5dfd722c09f98bdb1286b5465a049e40e6aff200f82ac79fa208a4988179b764b8924bdee87d18005a6430b55d46dd8d6158d3aadc0f804b3b204209519607baa33d9edcd992c5055d002be2d0e3a709bcc0dfdb947d5d221f56e802f7051eada44d4debf8b556abd42f0b776e0777f8396965464abb80473f73383dc9991886f6172c90422f250e64ae5e5fd9b2c73c637254cdc389c17bb1908ecd5926e2a9dcf560c62944c93174f8839f3b4458f0dec4681a7f43cb0b10a5ca28105241a6c42ad40945216cc07c2af8973f9d6abad6954f657a034f7261c758c849b92cfe6a07d3bcd5bde99a4b9027b22245885423b0f22e4b7b580210dcbbf48d2afd80a7a2c4afaa3a324cf30710b61577cebde2a37fa994037b795029219de791f3f842

Ok, seems to be pairing, then this happens:

Precondition failed: file /Users/btg/Documents/GitHub/HAP/.build/checkouts/swift-nio/Sources/NIO/ChannelPipeline.swift, line 153
[hap.endpoints|INFO] [IPv6]::ffff:10.11.175.194/::ffff:10.11.175.194:60975 POST /pair-setup 200 409
[hap.endpoints|DEBUG] Response Message: -

i am not sure if i am missing some key configuration not covered in the instalation process, what should i do?

icservis commented 5 years ago

Did you solved this issue? I have encountered the same issue. Thx

JulioBBL commented 5 years ago

Unfortunately not, tried a couple of thing without any sign of progress

Bouke commented 5 years ago

I was able to reproduce with the current master. It seems to stem from this PR: https://github.com/Bouke/HAP/pull/88/files#diff-ea8fc2297f6eeccad47215598cbe2fa7R40, when accessing context.channel in the async read-write queue. I'll have a look at what can be done to fix this.

Bouke commented 5 years ago

Fixed in b1999cb, thanks for the report!

Bouke commented 5 years ago

Beware that pairing is slow in a debug build; use swift run hap-server -c release for better performance.