ACI IPFS node connection issues

109 Views Asked by At

I have followed this tutorial for how to set up an IPFS node in an Azure container to set up two IPFS nodes, one in Europe and one in the US to do some benchmarking on how long it takes to retrieve a CID across the nodes. I have created a simple script for adding and retrieving data from these two nodes using ipfs-http-client.

// write.js
import * as IPFS from 'ipfs-http-client';

const main = async () => {
  const ipfs = IPFS.create({
    host: '<eu host>',
    port: '5001',
    protocol: 'http',
  });

  const { cid } = await ipfs.add(
    `Hello at ${new Date().toISOString()}`
  );

  console.log(cid);
};

main();
// read.js
import * as IPFS from 'ipfs-http-client';

const main = async () => {
  const ipfs = IPFS.create({
    host: '<us host>',
    port: '5001',
    protocol: 'http',
  });

  for await (const c of ipfs.cat(
    '<cid>'
  )) {
    console.log(new TextDecoder().decode(c));
  }
};

main();

If I read and write to the same node it works fine, however, the data stored in one node does not seem to be accessible from any other node anywhere, as if the nodes are not properly connected.

I have also tried using the same snippets of code to write data to the infura-ipfs gateway and retrieving it through the ipfs.io gateway which seems to work. This probably means I have just configured my nodes wrong, however I have no idea how to work around this issue. I have tried multiple solution to just get an IPFS node online but I have not succeeded in any way so far. Optimally, I need any two applications to be able to select any peer at random from a selected list and share the same data across nodes, preferably using pubsub.

1

There are 1 best solutions below

0
On

I assumed that IPFS would be able to discover content automatically, but by running the ipfs swarm connect <multiaddr> for each node to manually connect them to each other I finally got it working. If there is any way to make each node automatically discover each other and their content that would be amazing, but at least I have gotten one step further.