-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Not clear how to leave an IPFS node ready for new requests #1024
Comments
At first glance I can see that you are not terminating the
IPFS code base and examples rely heavily on the async library, but IPFS also supports a promise based interface, so doing |
Thanks a lot for your help. I've been trying what you suggested, which improved the example, but still no success. Then I get these errors:
Maybe I have to stop and restart the ipfs instance? Any pointers help, as I'm really eager to get this to work. I may be able to run it as a back-end service and spawn and terminate a node process each time but this seems suboptimal. |
@davidweisss I believe I can help you here. In the code linked above, the IPFS instance gets created here https://github.com/DNAvid/DNA-IDstorage/blob/b2f6f6aaf12f8c522536e74b814fd9dab3bb13d3/storageServer.js#L34. However, in order to make sure IPFS has properly started, one has to wait for the the "ready" event, eg. If you want to separate IPFS from your http-backend process, you can use js-ipfs-api to connect to a running go-ipfs daemon (replace I would also recommend to start the IPFS instance outside your endpoints. Eg. create IPFS instance here and put the Let us know if that doesn't work or if you have any questions! |
@davidweisss - here is what you're trying to do reworked a little bit:
I removed all the ssl parts for simplicity. The main issue was that you were re-using the read-write stream returned by In addition, and as suggested by @haadcode, in a node application you probably want to use an external IPFS instance through the ipfs-api module. |
That's so helpful. Thanks! |
It is now working, thank you! I didn't think of creating the server as a callback to IPFS instance 'ready' event. Clever! Re the external api instance, for security and portability, I am aiming ideally for a simple code base that doesn't touch the file system of the server where it runs, streaming the file to ipfs then deleting all content and credentials, by piping from client to RAM to remote ipfs server. But I confess I haven't gotten into the detail of how ipfs 'swarms' (?) work. Perhaps I need a separate server to 'pin' the content. Probably I just need to reference it by ip and port in the 'new IPFS()' options? My plan is to externalize the actual pinning and distribution with filecoin markets, but afaik it's still on the works, right? (The 'stream ended prematurely' errors are still appearing, not critical as the server doesn't crash.) Thanks again for the effort to answer outside the scope strictly of js-ipfs. |
I'm closing this issue, as the proof-of-concept is now working, Thanks!! |
03157b4
"ipfs": "^0.25.4"
Linux dnacoinstorage 4.10.0-32-generic IPFS Repo JavaScript Implementation #36-Ubuntu SMP Tue Aug 8 12:10:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Type: Question
Severity: Critical
Description:
I am working out of the example 1.js to provide a hosted service to encrypt upload files to ipfs. I removed the part in async/series where the process is exited.
I want the node to keep processing future requests.
The upload works great for the first upload but then hangs when a new request is received.
I've tried to stop the node then start it again, but there is something I must be missing because it doesn't work. Or this is not the way it is supposed to be used? Thanks for any insight as I've run out of ideas besides going deep in the source.
Steps to reproduce the error:
Upload one file, then try once again. Server hangs indefinitely.
It's on my hosted server: https://dnacoinstorage.com, please contact me if you'd like me to demo the issue.
The text was updated successfully, but these errors were encountered: