Js-ipfs swarm connect to pinata

Hello :wave: ,

I would like to connect to Pinata peers with an ipfs-core js-ipfs instance.

ipfs = await window.IpfsCore.create()
const addr = window.IpfsCore.multiaddr("/dnsaddr/fra1-3.hostnodes.pinata.cloud/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29") 
ipfs.swarm.connect(addr)

but this results in:

ipfs-core.min.js:26 Uncaught (in promise) Error: no protocol with name: "'p2p'". Must have a valid transport protocol: "{tcp, udp}".
    at Yn.nodeAddress (ipfs-core.min.js:26)
    at ynt (ipfs-core.min.js:113)
    at gnt (ipfs-core.min.js:113)
    at Array.sort (<anonymous>)
    at bnt (ipfs-core.min.js:113)
    at Lye.getMultiaddrsForPeer (ipfs-core.min.js:118)
    at tpe._createDialTarget (ipfs-core.min.js:117)
    at tpe.connectToPeer (ipfs-core.min.js:117)
    at Ub._dial (ipfs-core.min.js:118)
    at Ub.dial (ipfs-core.min.js:118)

Where is the issue here? The bootstrap addresses look similar.

The port is missing, it should be: "/dnsaddr/fra1-3.hostnodes.pinata.cloud/tcp/<port>/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29"

You can get correct peer addresses by:
ipfs dht findpeer QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29

/ip4/127.0.0.1/tcp/4001
/dnsaddr/fra1-3.hostnodes.pinata.cloud/udp/4001/quic
/p2p-circuit/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29/ip4/0.0.0.0/tcp/0
/ip4/64.225.105.42/tcp/4001/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29
/ip6/::1/tcp/4001
/ip4/64.225.105.42/tcp/4001
/ip6/2a03:b0c0:3:e0::451:c001/tcp/4001
/dnsaddr/fra1-3.hostnodes.pinata.cloud/tcp/4001
/dnsaddr/fra1-3.hostnodes.pinata.cloud

Taking it further, we can see what the dnsaddr will resolved to as explained in this documentation:

dig +short txt _dnsaddr.fra1-3.hostnodes.pinata.cloud

which yields:

dnsaddr=/ip4/64.225.105.42/tcp/4001/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29"

However, if we try one of the default bootstrap nodes:

dig +short txt _dnsaddr.bootstrap.libp2p.io 

We get:

"dnsaddr=/dnsaddr/ams-2.bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/dnsaddr/ams-rust.bootstrap.libp2p.io/p2p/12D3KooWEZXjE41uU4EL2gpkAQeDXYok6wghN7wwNVPF5bwkaNfS"
"dnsaddr=/dnsaddr/ewr-1.bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
"dnsaddr=/dnsaddr/nrt-1.bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"dnsaddr=/dnsaddr/sjc-1.bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"
"dnsaddr=/dnsaddr/sjc-2.bootstrap.libp2p.io/p2p/QmZa1sAxajnQjVM8WjWXoMbmPd7NsWhfKsPkErzpm9wGkp"

And further:

❯ dig +short txt _dnsaddr.ams-2.bootstrap.libp2p.io
─╯
"dnsaddr=/dns4/ams-2.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/dns6/ams-2.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/ip4/147.75.83.83/tcp/4001/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/ip4/147.75.83.83/udp/4001/quic/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/ip6/2604:1380:2000:7a00::1/tcp/4001/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/ip6/2604:1380:2000:7a00::1/udp/4001/quic/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"

which provides wss protocols instead of just tcp, which is not supported in browsers.

thanks for the awesome information.