`ipfs swarm connect` between daemons in IPFS cluster

Hi guys, hope you guys are having a good weekend.

I have a setup of 2 containers, each container having 1 cluster peer and 1 daemon. These 2 containers form a cluster.

Here is my docker-compose file: docker-compose.yml · GitHub

I successfully added file via the cluster HTTP API and got the CID correctly pinned in both 2 peers when having query param local=false. However, when I used local=true, the CID was only successfully pinned on the requested peer, while the other got context cancelled error.

Inspecting the log, I find that this may be because one daemon cannot establish the swarm connection to the other so that the actions are timed-out.

Here is the log:

ipfs-cluster-peer_2  |   ipfshttp	ipfshttp/ipfshttp.go:682	IPFS request unsuccessful (swarm/connect?arg=%2Fip4%2F172.27.0.2%2Fudp%2F4001%2Fquic%2Fp2p%2F12D3KooWHr8tHvKNn4isWxhRGwEzZCwpDnn9HLKPQkLLRx1CM5rS). Code: 500. Message: connect 12D3KooWHr8tHvKNn4isWxhRGwEzZCwpDnn9HLKPQkLLRx1CM5rS failure: failed to dial 12D3KooWHr8tHvKNn4isWxhRGwEzZCwpDnn9HLKPQkLLRx1CM5rS:
ipfs-cluster-peer_2  |   * [/ip4/172.27.0.2/tcp/4001] dial tcp4 0.0.0.0:4001->172.27.0.2:4001: i/o timeout
* [/ip4/172.27.0.2/udp/4001/quic] context deadline exceeded
ipfs-cluster-peer_2  |   * [/ip4/113.172.236.221/udp/56885/quic] timeout: no recent network activity

Wonder if there is anything wrong in my config. Really appreciate any help.

Thanks in advance.

You IPFS daemons perhaps don’t have connectivity between each others or perhaps cannot discover each other (the IPs they announce are not the ones they can be reached at).

You can use docker exec to run ipfs id and ipfs swarm connect manually etc.

1 Like

Thanks Hector,

Manual ipfs swarm connect solved the problem.

Still figuring out how to achieve auto-discovery between containers. I exposed 4001 port but no luck.

The current solution is that I have to manually edit the Addresses.Announce to announce the appropriate address. Still looking for a fully automated way because that will help a lot when we do automated deployments.

Just an update.

One of the solutions is used ipfs config cmd. For example:

ipfs config --json Addresses.Announce "[..array of multiaddresses]"