brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

Can't pass the key exchange #170

Closed maaraneasi closed 4 years ago

maaraneasi commented 4 years ago

Hi,

This is not directly related to HC itself but I think I might need another set of eyes (from someone who knows the hap protocol).... I am trying to run an app using HC on a kubernetes cluster but I can see my bridge on the network only once and I am not able to add any accessories from this bridge. If I delete the data dir, I see the bridge on the network (again) but also only unless I try to add it. When checking the logs I found that very last communication between the app and my phone was the key exchange:

DEBUG 2020/03/30 14:58:05 pair-setup.go:44: 192.168.1.65:57057 POST /pair-setup

DEBUG 2020/03/30 14:58:05 pair-setup.go:55: Create new pair setup controller

DEBUG 2020/03/30 14:58:06 setup_server_controller.go:106: <-     B: 5f648132e51fb2e97ed2c9e6411add16a39bb88b02732ab7e3c2d3c5fcba557f2161355c35e8a44e8d0e5c0356e850b5556532ef44b32586b634b565c99060d921da29c53bec1c7cdd4e404ea86654b848265dbdf6d9a80c0670e09ea16db43592461fbb2a7d5dcb6456a8a44017212d45adaf494d25dd7962a884fa2e6fe015e8db29a3fa691572147ffdbdf34de5b468ad086a739a89680ff1e108da0b859d8a766414a296174c6acec4e9bf3da009143f404a44ef9fae62bea9afae6bd48cf3bec71cc92c31563f922f80b0dedb1181871de58f2069a1215d618c406eef562b25d014575309715d3eb2261f6e88baaa8b7b096662b30812090d332b873a13f8a6dba21e2964268e701534b03cf33c863ceb86f4d467e3181a2c5dd2a0e84b830cee3c848968ff81060be8322696cc8b1b93c47a763deae44322189ddd73e5f21c8aebc5dc0cfdfc38a512b40f62f05571b553c77f7fdf3803b9093a83ed55691383d521256a8356b99bc9ca0b82b464156696c67df0c2b19a92b54c3f74a

DEBUG 2020/03/30 14:58:06 setup_server_controller.go:107: <-     s: 042672c9dce7bcac53d2b8cc021f30e7

DEBUG 2020/03/30 14:58:09 connection.go:112: Close connection and remove session

The question is - what is the communication that hc is trying to do when adding the bridge to the phone app? I suspect the problem is in the network communication between the phone app and the hc but I have no idea how to identify the real problem.... I checked the code, and this message comes from func (endpoint *PairSetup) ServeHTTP(response http.ResponseWriter, request *http.Request) where the app setups an endpoint for the key exchange and is trying to connect to 192.168.1.65:57057 (an iphone).... Where does this port come from? What are all the ports that hc is using? - I thought that its only the port I set for the transport and 5353 for the mDNS.

Thanks!

brutella commented 4 years ago

The connection is established from the iOS device to your bridge, not the other way around. The IP address that you quoted is the remote IP address that connects to hc.

brutella commented 4 years ago

Closed due to inactivity