Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

swarm.connect: Error: multiaddr must have a valid format #3501

Closed
tymmesyde opened this issue Jan 22, 2021 · 3 comments
Closed

swarm.connect: Error: multiaddr must have a valid format #3501

tymmesyde opened this issue Jan 22, 2021 · 3 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@tymmesyde
Copy link

  • Version: 0.53.2
  • Platform: Windows 10 / Brave 1.19.86
  • Subsystem: libp2p

Severity: High

Description:

I have one peer trying to connect to another one with only his CID using: ipfs.swarm.connect('/p2p-circuit/p2p/${peerId}')
And got this error:
Error: multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".

At first I was using ipfs@0.50.2 with ipfs.swarm.connect('/p2p-circuit/ipfs/${peerId}') and worked just fine.
So I dig around and found that it's now preferable to use p2p instead of ipfs for the multiaddress but still didn't resolve anything.

I found that ipfs.swarm.connect is using the dial function of libp2p, so I'm not sure if this an issue only related to libp2p.

I also tried to use the get function of the addressBook present in libp2p to find the precise mutliaddress to use but with the same result:

const peerID = PeerId.createFromCID(CID);
const addressBook = await this.ipfs.libp2p.peerStore.addressBook.get(peerID);

const multiaddress = addressBook[0].multiaddr.toString(); // /dns4/akasha.cloud/tcp/443/wss/p2p-webrtc-star/p2p/${CID}
await this.ipfs.swarm.connect(multiaddress );

So what should I do, is there something that I'm missing here ?

Steps to reproduce the error:

Two nodes running in the browser using this config:

await create({
    libp2p: {
        config: {
            dht: {
                enabled: true
            }
        }
    },
    config: {
        Addresses: {
            Swarm: [
                '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star/',
                '/dns4/akasha.cloud/tcp/443/wss/p2p-webrtc-star/'
            ]
        }
    }
});

Get the CID of the first one and try to connect to the first with the second one using:

await ipfs.swarm.connect('/p2p-circuit/p2p/${peerId}')
@tymmesyde tymmesyde added the need/triage Needs initial labeling and prioritization label Jan 22, 2021
@welcome
Copy link

welcome bot commented Jan 22, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

A circuit relay address is an instruction of how to route through a relay node to an otherwise inaccessible node.

It takes the form ${relayNodeAddr}/p2p-circuit/${targetNodeAddr}

For example, let's say I'm at home and I have a running node I can dial a node running on my home computer which I can access via /ip4/192.168.1.6/tcp/38231/p2p/Qmfoo when I'm on my home network.

Obviously I can't dial that directly from my place of work because 192.68.x.x is a private address, but if I have a relay on my home network with NAT hole punching enabled, and the external IP address of my home router is 82.31.24.65 I could dial something like:

/ip4/82.31.24.65/tcp/39823/p2p/QmRelay/p2p-circuit/ip4/192.168.1.6/tcp/38231/p2p/QmTarget

This is saying "dial /ip4/82.31.24.65/tcp/39823/p2p/QmRelay then tell the relay to dial /ip4/192.168.1.6/tcp/38231/p2p/QmTarget and forward all the traffic backwards and forwards".

If the relay already has a connection to the target node, I can omit the ip4/tcp part of the target node address:

/ip4/82.31.24.65/tcp/39823/p2p/QmRelay/p2p-circuit/p2p/QmTarget

The address you are trying to dial (/p2p-circuit/p2p/${peerId}) is incomplete. You need to add the relay address in at the front.

I believe this used to work in go-IPFS under the right network conditions, but it was removed because it gave the impression it was supposed to work but was really only functional by coincidence.

Please see the circuit relaying example for more information.

@tymmesyde
Copy link
Author

Thank you for the full explanation, it's more clear to me now.
Sorry for opening the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

2 participants