1

I installed ipfs in my mac as follows:

docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 4001:4001/udp -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/kubo:latest

Then in my nodejs app, I installed

"ipfs-http-client": "^56.0.3",

In my ipfsservice.js, I try to get the id:

const client = require("ipfs-http-client");

const ipfs = client.create("/ip4/127.0.0.1/tcp/5001");

const test = async () => {
  const id = await ipfs.id();
  console.log(id);
};

module.exports = { test };

In the main app, I just call test() then got the following error:

/mynodejsproj/node_modules/multiaddr/src/protocols-table.js:22
    throw new Error('no protocol with name: ' + proto)
      ^

Error: no protocol with name: quic-v1
at Protocols (/mynodejsproj/node_modules/multiaddr/src/protocols-table.js:22:11)
at stringToStringTuples (/mynodejsproj/node_modules/multiaddr/src/codec.js:48:19)
at stringToBytes (/mynodejsproj/node_modules/multiaddr/src/codec.js:220:13)
at Object.fromString (/mynodejsproj/node_modules/multiaddr/src/codec.js:231:10)
at new Multiaddr (/mynodejsproj/node_modules/multiaddr/src/index.js:56:26)
at /mynodejsproj/node_modules/ipfs-http-client/cjs/src/id.js:23:53
at Array.map (<anonymous>)
at Object.id (/mynodejsproj/node_modules/ipfs-http-client/cjs/src/id.js:23:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.test (/mynodejsproj/service/ipfs.service.js:8:14)
iPhoneJavaDev
  • 821
  • 5
  • 33
  • 78

2 Answers2

0
const client = require("ipfs-http-client");

const ipfs = client.create({
  url: "http://127.0.0.1:5001",
  headers: {
    "access-control-allow-origin": "*",
  },
  options: {
    protocol: "http",
    host: "127.0.0.1",
    port: 5001,
  },
});

const test = async () => {
  const id = await ipfs.id();
  console.log(id);
};

module.exports = { test };
Anaam
  • 124
  • 6
0

The upgrade of ipfs-go from 0.13.x to 0.19.x add "Swarm"

  •  "/ip4/x.x.x.x/udp/4001/quic-v1",
    
  •  "/ip4/x.x.x.x/udp/4001/quic-v1/webtransport",
    
  •  "/dnsaddr/domain.name/tcp/4001/quic-v1",
    
  •  "/dnsaddr/domain.name/tcp/4001/quic-v1/webtransport",
    

The ipfs-http-client 56.0.3 get the endpoint list from fipfs.id() The list provided by ipfs-go v0.19.x is not compatible with ipfs-http-client 56.0.3.

On your ipfs-go server modify your config file and remove the lines that says

  •  "/ip4/x.x.x.x/udp/4001/quic-v1",
    
  •  "/ip4/x.x.x.x/udp/4001/quic-v1/webtransport",
    
  •  "/dnsaddr/domain.name/tcp/4001/quic-v1",
    
  •  "/dnsaddr/domain.name/tcp/4001/quic-v1/webtransport",
    

Restart the server, the client library should be alright now.