textileio / go-textile

[DEPRECATED] Textile is a set of tools and infrastructure for building composable apps and services on the IPFS network
https://textile.io
MIT License
357 stars 43 forks source link

Difficult to `contacts add` if peers are not directly connected #613

Open flyskywhy opened 5 years ago

flyskywhy commented 5 years ago

With go-textile_v1.0.0-rc51_linux-amd64.tar.gz

On computer A (behind a NAT) and computer B (behind a NAT)

$ textile ipfs swarm connect /ip4/18.184.60.108/tcp/4001/ipfs/QmQUPL5gvWp3VDBrouhpZx2L6un2ZBzMbLmcnjK45TMuVv
[
    "connect QmQUPL5gvWp3VDBrouhpZx2L6un2ZBzMbLmcnjK45TMuVv success"
]

then

On computer A

$ textile ipfs swarm connect /ipfs/QmQUPL5gvWp3VDBrouhpZx2L6un2ZBzMbLmcnjK45TMuVv/p2p-circuit/ipfs/12D3KooWP3u4Hyg2to92K9X9Ke5naLcRbgE5njCr5ybtJs3F3ybT
[
    "connect 12D3KooWP3u4Hyg2to92K9X9Ke5naLcRbgE5njCr5ybtJs3F3ybT success"
]

BTW, 12D3KooWP3u4Hyg2to92K9X9Ke5naLcRbgE5njCr5ybtJs3F3ybT comes from ~/.textile/repo/config PeerID of computer B

I can confirm computer A and B is connected with relay peer /ip4/18.184.60.108/tcp/4001/ipfs/QmQUPL5gvWp3VDBrouhpZx2L6un2ZBzMbLmcnjK45TMuVv by

textile ipfs swarm peers | grep QmQUPL5gvWp3VDBrouhpZx2L6un2ZBzMbLmcnjK45TMuVv -A3

but when I run on computer A

textile contacts add -p 12D3KooWP3u4Hyg2to92K9X9Ke5naLcRbgE5njCr5ybtJs3F3ybT
No contacts were found

when I run it in many times about 20 times, there will be a

Add 1 contact? [y/n]: n

On computer C (public, not behind a NAT) and computer D (public, not behind a NAT), if I did not textile ipfs swarm connect them directly, textile contacts add will No contacts were found

In terminal 1 and terminal 2 (repo use .textile2) On computer E, textile contacts add even invites and chat works well with the two terminal.

So why contacts add is so difficult on different computers? Because relay connected not directly connected?

sanderpick commented 5 years ago

Hmm, they shouldn't need to be direct connected. Search works via gossipsub for this very reason. I'll have to investigate further.