n0-computer / beetle

Other
35 stars 15 forks source link

Providers are not found in local network setup #68

Open fabricedesre opened 2 years ago

fabricedesre commented 2 years ago

Configuration: running iroh-one on 2 machines on the same local network, with no p2p bootstrap peers. Discovery happens just fine over mDNS.

Use the branch at https://github.com/capyloon/iroh/commit/a7c3b15f0bdc2e1a15092aab31f3afe9cc1f7b07#diff-4d226c1c8b9372b073d09fa48265e9826c6886a744b6b892eb2c2d800af9d18a to push some content to machine1with:

#!/bin/bash

curl 'http://machine1:9050/ipfs/' \
  -v \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: text/plain;charset=UTF-8' \
  -H 'Origin: null' \
  -H 'Pragma: no-cache' \
  --data-raw 'Hello Capyloon!'

The CID bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm is getting provided. Check that the CID is in store with curl http://machine1:9050/ipfs/bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm

Then from machine2, wait for both peer counts to reflect the mDNS discovery, and try to fetch the same CID locally: curl http://localhost:9050/ipfs/bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm

I see that log in machine2:

  2022-11-22T18:56:33.182383Z  INFO iroh_p2p::node: bitswap find providers bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm
    at iroh-p2p/src/node.rs:465
    in iroh_p2p::node::handle_node_event with event: Bitswap(FindProviders { key: Cid(bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm), response: Sender { chan: Tx { inner: Chan { tx: Tx { block_tail: 0x7fd1fc0155a0, tail_position: 0 }, semaphore: Semaphore { semaphore: Semaphore { permits: 10 }, bound: 10 }, rx_waker: AtomicWaker, tx_count: 1, rx_fields: "..." } } }, limit: 10 })
    in iroh_p2p::node::handle_swarm_event with event: Behaviour(Bitswap(FindProviders { key: Cid(bafkreia5so3urvs3o5mvguua7othrzg5ssz6djdwqtywrmc6m5l7h7wlnm), response: Sender { chan: Tx { inner: Chan { tx: Tx { block_tail: 0x7fd1fc0155a0, tail_position: 0 }, semaphore: Semaphore { semaphore: Semaphore { permits: 10 }, bound: 10 }, rx_waker: AtomicWaker, tx_count: 1, rx_fields: "..." } } }, limit: 10 }))

But nothing relevant on machine1, and the request times out.

@dignifiedquire in p2p/src/node.rs the BitswapEvent::FindProviders triggers a RpcMessage::ProviderRequest with a ProviderKey::Dht only, could that be why mDNS providers discovery is not working?

dignifiedquire commented 2 years ago

@dignifiedquire in p2p/src/node.rs the BitswapEvent::FindProviders triggers a RpcMessage::ProviderRequest with a ProviderKey::Dht only, could that be why mDNS providers discovery is not working?

No that is not the reason, this part of finding providers is only used as a fallback by bitswap to find providers if it can not find them via bitswap.