functionland / go-fula

Client-server stack for Web3! Turn your Raspberry Pi to a BAS server in minutes and enjoy the freedom of decentralized Web with a superior user experience!
MIT License
13 stars 6 forks source link

hole punching not work on slow connection due to timeout. #32

Closed farhoud closed 1 year ago

farhoud commented 2 years ago

Find out where I can find timeout. Output log of go-fula/mobile test:

2022-07-30T17:36:59.467+0430    DEBUG   p2p-holepunch   holepunch/svc.go:108    Host now has a public address. Starting holepunch protocol.
2022-07-30T17:37:18.516+0430    DEBUG   p2p-holepunch   holepunch/svc.go:199    received hole punch request     {"peer": "12D3KooWMRfhfGvpBfV7qZZs3fsQZfpQpjWC8CqV1YdjXRX4uSwd", "addrs": ["/ip4/178.131.215.204/udp/50256/quic"]}
2022-07-30T17:37:19.265+0430    DEBUG   p2p-holepunch   holepunch/svc.go:257    starting hole punch     {"peer": "12D3KooWMRfhfGvpBfV7qZZs3fsQZfpQpjWC8CqV1YdjXRX4uSwd"}
2022-07-30T17:37:24.265+0430    DEBUG   p2p-holepunch   holepunch/util.go:64    hole punch attempt with peer failed     {"peer ID": "12D3KooWMRfhfGvpBfV7qZZs3fsQZfpQpjWC8CqV1YdjXRX4uSwd", "error": "context deadline exceeded"}
    /home/farhoud/workspace/functionland/go-fula/mobile/fula_test.go:147: send failed failed to dial 12D3KooWMRfhfGvpBfV7qZZs3fsQZfpQpjWC8CqV1YdjXRX4uSwd:
          * [/ip4/172.17.0.2/udp/4001/quic] hole punching attempted; no active dial
          * [/ip4/178.131.215.204/udp/50256/quic] hole punching attempted; no active dial
          * [/ip4/172.17.0.2/tcp/4001] dial tcp4 172.17.0.2:4001: i/o timeout
--- FAIL: TestEncryption (28.56s)
FAIL
FAIL    github.com/functionland/go-fula/mobile  28.584s
mehdibalouchi commented 2 years ago

Adding to the above logs This is the log for Kubo when go-fula/mobile attempts to connect:

2022-07-30T12:59:11.649Z    DEBUG   p2p-holepunch   holepunch/svc.go:199    received hole punch request{"peer": "12D3KooWAERBS8XvDNopxeqMZnDEyHEefB83bPeE3wM8tSte1mrs", "addrs": ["/ip6/64:ff9b::5445:2141/udp/4001/quic","/ip4/84.69.33.65/tcp/4001","/ip4/84.69.33.65/udp/4001/quic"]}
2022-07-30T12:59:11.997Z    DEBUG   p2p-holepunch   holepunch/svc.go:257    starting hole punch {"peer": "12D3KooWAERBS8XvDNopxeqMZnDEyHEefB83bPeE3wM8tSte1mrs"}
2022-07-30T12:59:12.923Z    DEBUG   p2p-holepunch   holepunch/util.go:67    hole punch successful   {"peer": "12D3KooWAERBS8XvDNopxeqMZnDEyHEefB83bPeE3wM8tSte1mrs"}
2022-07-30T12:59:38.092Z    DEBUG   p2p-holepunch   holepunch/holepuncher.go:132    got inbound proxy conn  {"peer": "12D3KooWKrYvhXiLQTpamegFyErSMN7tjpSqqrwVnh1txT3TEuEU"}
2022-07-30T12:59:39.741Z    DEBUG   p2p-holepunch   holepunch/holepuncher.go:143    peer RTT is 543.353208ms; starting hole punch in 271.676604ms
2022-07-30T12:59:45.017Z    DEBUG   p2p-holepunch   holepunch/util.go:64    hole punch attempt with peer failed {"peer ID": "12D3KooWKrYvhXiLQTpamegFyErSMN7tjpSqqrwVnh1txT3TEuEU", "error": "failed to dial 12D3KooWKrYvhXiLQTpamegFyErSMN7tjpSqqrwVnh1txT3TEuEU:\n  * [/ip6/::1/tcp/4001] dial tcp6 [::1]:4001: connect: cannot assign requested address\n  * [/ip4/192.168.1.10/tcp/4001] dial tcp4 0.0.0.0:4001->192.168.1.10:4001: i/o timeout\n  * [/ip4/91.98.172.173/tcp/2112] dial tcp4 0.0.0.0:4001->91.98.172.173:2112: i/o timeout"}
2022-07-30T12:59:47.713Z    DEBUG   p2p-holepunch   holepunch/holepuncher.go:143    peer RTT is 2.694861292s; starting hole punch in 1.347430646s
2022-07-30T12:59:54.064Z    DEBUG   p2p-holepunch   holepunch/util.go:64    hole punch attempt with peer failed {"peer ID": "12D3KooWKrYvhXiLQTpamegFyErSMN7tjpSqqrwVnh1txT3TEuEU", "error": "context deadline exceeded"}
2022-07-30T12:59:54.064Z    DEBUG   p2p-holepunch   holepunch/holepuncher.go:138    hole punching failed    {"peer": "12D3KooWKrYvhXiLQTpamegFyErSMN7tjpSqqrwVnh1txT3TEuEU", "error": "failed to open hole-punching stream: no usable connection to peer"}

The log indicates that the timeout for hole punching gets exceeded.