Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Can't connect to ipfs daemon from node 'ready' callback. #1207

Closed
10thfloor opened this issue Feb 6, 2018 · 3 comments
Closed

Can't connect to ipfs daemon from node 'ready' callback. #1207

10thfloor opened this issue Feb 6, 2018 · 3 comments
Labels
kind/support A question or request for support

Comments

@10thfloor
Copy link

  • Version: js-ipfs version: 0.27.7
  • Platform: 17.3.0 Darwin Kernel Version 17.3.0: root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

Type: Question

Severity: Low

Description:

Hello, I have a question about the intended functionality of the ipfs node instance.


const IPFS = require('ipfs');
const API = require('ipfs-api')

const node = new IPFS()

node.on('ready', () => {

    const ipfs = API('localhost', '5002', { protocol: 'http' })
   
    // Attempt to ask the API for anything. 
    // ipfs.id is used as an example here but all other methods fail.

    ipfs.id(function (err, identity) {
      if (err) {
        throw err
      }
      console.log(identity)
    })
})

Steps to reproduce the error:

Running the above code with node produces:

{ Error: connect ECONNREFUSED 127.0.0.1:5002
    at Object._errnoException (util.js:1031:13)
    at _exceptionWithHostPort (util.js:1052:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5002 }

I'm wondering if the ipfs constructor starts an ipfs daemon, or if the daemon must be started manually, from the cli?

Does new IPFS() start the ipfs daemon? The docs are unclear about this. (At least for me).

Thanks! ✌️

@daviddias daviddias added the kind/support A question or request for support label Feb 7, 2018
@daviddias
Copy link
Member

Hi @10thfloor. The new IPFS() starts an IPFS instance, not the daemon. You don't need to connect to it with the ipfs-api (which is the HTTP Client Library).

To start a js-ipfs Daemon, you can use the ipfsd-ctl module

@10thfloor
Copy link
Author

Excellent. The ipfs-ctl module is what I was looking for. It works perfectly. Thank you!

@daviddias
Copy link
Member

Awesome :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants