7

I am using IPFS version 0.4.4.

My goal is to connect two peers in order to prevent IPFS peer to halt on reading an IPFS-hash from the shared peer. In order to achieve it, I am using ipfs swarm connect to connect peer-A to peer-B, where peer-B can access ipfs-file on peer-A.

My question is related to:

ipfs swarm connect /ip4/x.x.x.x/tcp/4003/ipfs/QmXXXXXXXXXXXXXXXXXXX

When I try to connect my laptop to another IPFS-peer, I face with following error:

connect failure: dial attempt failed: context deadline exceeded.

But when I try on an Amazon AWS where all the ports are open, it works, hence swarm connect ended as success.

[Q] In order to make ipfs swarm connect work should API and Gateway port should be open? or should I do something else?

For example should: port 5001 and 8080 be open no matter what?

.ipfs/config file:

"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080",

1 Answer 1

1

I believe you don't have to open API and Gateway ports to be able to connect to your peer. Instead, just try checking your connectivity from the outside:

telnet x.x.x.x yyyy 

#Trying x.x.x.x...
#Connected to x.x.x.x.
#Escape character is '^]'.
#/multistream/1.0.0

You can see the port in Addresses section of IPFS config, in my case it's 4001:

  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001"
    ],

but since the host is behind NAT, the actual IP where it can be accessed can't be detected by IPFS daemon, so I had to put it to Announce section, like

"Announce": ["/ip4/z.z.z.z/tcp/4001"],

After finding the right IP and port, I was able to connect:

ipfs swarm connect /ip4/z.z.z.z/tcp/4001/ipfs/QmXXX_my_peer_id_XXX
#connect QmXXX_my_peer_id_XXX success
9
  • Does z.z.z.z stands for the IP address? Inside config file I was not able to find Announce section. I guess you put it under Addresses. @Utgarda
    – alper
    Sep 23, 2018 at 16:39
  • Yep, z.z.z.z. is an IP4 address. My IPFS version is 0.4.17, and I had Announce right away in its generated config, it was empty, "Announce": [],. Try putting it after "Swarm":[...],. What's your IPFS version btw?
    – Utgarda
    Sep 23, 2018 at 16:42
  • Well, what does your connectivity test show you? Try telnet from your IPFS host and outside it too.
    – Utgarda
    Sep 23, 2018 at 16:49
  • What does yyyy stands for , is it 4001 on your example? telnet x.x.x.x yyyy returns Trying x.x.x.x... after I added Announce part. Please note that Gateway and API ports are closed on the machine that I am trying to connect into. @Utgarda
    – alper
    Sep 24, 2018 at 8:37
  • 1
    Got it. This works as well: sudo lsof -n -i :4001 | grep LISTEN @Utgarda
    – alper
    Sep 24, 2018 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.