I try to preload some data on IPFS through preload nodes and retrieve them from an IPFS gateway.
This used to work (with some minor exceptions of one or another preload node being periodically down) but it is no longer the case whatever preload node is used.
Are public preload (node[0-3].preload.ipfs.io) still ready to accept preload requests?
Hello thank you for the quick answer and the head up on pomegrenate project.
To give a little more context, I use ipfs-js in an isomorphic library (node & browser) to provide a simple way for users to upload some data that require global availability for a short while.
As I understand big changes are coming in the next few months and we should prepare to migrate from ipfs-js.
Meanwhile, I still need to provide the “upload to IPFS” feature but the default preload mechanism does not work anymore for me.
Running my own preload to have more control over it could be an option but I’m not sure it helps.
Here are the steps to reproduce the observed issue with node 16 & npm@8
mkdir ipfs-debug
cd ipfs-debug/
npm i ipfs node-fetch@2
touch index.js
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/QmQUNt8uu1J7ohvZMYhY7gm5omAaXvSnxQyqzmjFxyPLrA
Swarm listening on /ip4/192.168.1.103/tcp/4002/p2p/QmQUNt8uu1J7ohvZMYhY7gm5omAaXvSnxQyqzmjFxyPLrA
Swarm listening on /ip4/172.240.51.1/tcp/4002/p2p/QmQUNt8uu1J7ohvZMYhY7gm5omAaXvSnxQyqzmjFxyPLrA
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/QmQUNt8uu1J7ohvZMYhY7gm5omAaXvSnxQyqzmjFxyPLrA
ipfs:preload https://node3.preload.ipfs.io/api/v0/refs?r=true&arg=QmRL41zVdzdMAUDHQL1pQdkLtLv7HtVaaSoTnj2eF1Any4 +0ms
cid: QmRL41zVdzdMAUDHQL1pQdkLtLv7HtVaaSoTnj2eF1Any4
fetching QmRL41zVdzdMAUDHQL1pQdkLtLv7HtVaaSoTnj2eF1Any4 from IPFS gateway https://ipfs.io
/home/pierre/ipfs-debug/index.js:19
if (!res.ok) throw Error(`IPFS gateway bad response: ${res.status}`);
^
Error: IPFS gateway bad response: 504
at /home/pierre/ipfs-debug/index.js:19:24
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async preloadRandomBytes (/home/pierre/ipfs-debug/index.js:18:3)
we can see:
the ipfs.add(buffer, { preload: true }) promise resolves
fetching the data from ipfs.io gateway ends with an HTTP 504 while the local node is still running
NB:
I know propagation in the network may be slow, so I tried retries on the fetch part with no luck
One path that might be worth exploring is running a Kubo node and exposing the add endpoint of the Kubo RPC API (note that to expose only that endpoint you will likely need a reverse proxy like nginx or a middleware HTTP server that only passes through requests to that endpoint).
One of my requirements is to keep things as much decentralized (or a least distributed) as possible. That’s why I would prefer running a preload node (exposing the refs api) and adding it to the preload nodes list of ipfs-js to provide a fallback rather than directly uploading content on a node via /api/v0/add, I may run and trust this node but devs using my lib may not.
In the linked post you said
Preload are nodes that expose the /api/v1/refs endpoint […]
I thought the refs endpoint was under the v0 api (/api/v0/refs) is it a typo?
Edit: kubo + js-kubo-rpc-client works fine for direct upload
That’s understandable, though beware that preload nodes will go down. The preload pattern is not sustainable for two reasons:
Uploads are implicit — when you can the refs endpoint, you rely on the preload node pulling from a browser tab. Because browsers impose resource and network restrictions, pulling can fail even if you just change to another tab.
There’s no support for an authentication mechanism, so they can often be abused.
It sounds like you may be experiencing an issue with loading data from IPFS using the ipfs-js library. There are a few potential causes for this issue:
The IPFS node you are trying to connect to may be down or unavailable.
The data you are trying to load may not exist on the IPFS network.
There may be an issue with your code that is preventing the data from being loaded properly.
To troubleshoot the issue, you can try the following:
Verify that the IPFS node you are connecting to is up and running.
Check that the data you are trying to load is available on the IPFS network by using a tool like the IPFS explorer.
Verify that your code is using the correct syntax and parameters when trying to load the data from IPFS.
Ensure that your application has the correct permissions to access the IPFS network
Try to reproduce the problem with other libraries or tools
It would be helpful if you can provide more information about your code, the environment, and the error message you receive, so I can give you a more accurate solution.
Yes, that’s a good point, I used to fetch the preloaded document in the browser tab from another IPFS gateway to ensure the upload was successful.
Isn’t a publicly exposed /api/v0/add endpoint of a kubo node subject to similar abuse?
I’m currently running for tests propose a kubo:v0.18.0-rc.2 with wss enabled and full API exposed
uploading data to that node works with both direct add and preload
I can fetch the uploaded content from the gateway of another node my company hosts (that node is a go-ipfs:v0.9)
I can fetch the content from the pinata gateway
but I can’t fetch the uploaded content from the public https://ipfs.io gateway, should I do something (other than opening 4001) to make my node discoverable by the node exposing the public gateway?
Erratum:
With prelaod method, I sometimes get the uploaded document from the ipfs.io public gateway. I observed a call to a delegate node, when this call fails the public gateway also fails to serve the uploaded document. So the problem might not come from preload nodes?