ipfs-daemon icon indicating copy to clipboard operation
ipfs-daemon copied to clipboard

eleactron main.js try to use ipfs daemon

Open josselinchevalay opened this issue 8 years ago • 9 comments

Hi haad,

i try to use your node_module in my electron app to control IPFS daemon but i have an issue with event emitter :

const homePath = path.join(app.getPath('home'), '.telecope');
const ipfsPath = path.join(app.getPath('home'), '.ipfs');

const IPFSOptions = {
  IpfsDataDir: (process.env.IPFS_PATH) ? process.env.IPFS_PATH :  ipfsPath, // Location of IPFS data repository 
  LogDirectory: homePath, // Directory to write ipfs-daemon.log file for ipfs-daemon 
  Flags: [], // Flags to pass to IPFS daemon 
  Addresses: { // IPFS Daemon addresses 
    API: '/ip4/127.0.0.1/tcp/5001',
    Swarm: ['/ip4/0.0.0.0/tcp/4001'],
    Gateway: '/ip4/0.0.0.0/tcp/8080'
  },
  API: { // API config for IPFS daemon 
    HTTPHeaders: {
      "Access-Control-Allow-Origin": ['*'], // Origins from which to allow http requests 
      "Access-Control-Allow-Methods": ["PUT", "GET", "POST"], // "PUT", "GET", "POST", "DELETE", etc. 
      "Access-Control-Allow-Credentials": [] // "true" || "false" 
    } 
  },
  SignalServer: '127.0.0.1' // WebRTC sig-star server, browser only, eg. '127.0.0.1' 
};
console.log('starting ipfs daemon ...');
const ipfs = new IPFS(IPFSOptions);
ipfs.on('error', (error) => console.error(error));
ipfs.on('ready', () => {
  console.log('ipfs daemon started !');
  app.on('ready', createWindow);
});

i cannot see my log 'ipfs daemon started' or an error ... any idea ?

thx in advance !

josselinchevalay avatar Dec 18 '16 11:12 josselinchevalay

@josselinchevalay Thank you for reporting the issue! As per our discussion on IRC, can you run your code with LOG=debug electron . and paste the log here? That would help us to figure out what's going wrong.

haadcode avatar Dec 20 '16 14:12 haadcode

Hi haad,

i'm sorry for the waiting ....

i run this command :

LOG=debug IPFS_PATH=/tmp/somethingelse electron dist/main.js
2016-12-23T18:05:54.020Z [DEBUG] ipfs-daemon: Initializing IPFS daemon
2016-12-23T18:05:54.021Z [DEBUG] ipfs-daemon: Using IPFS repo at '/tmp/somethingelse'
2016-12-23T18:05:59.573Z [DEBUG] ipfs-daemon: Starting IPFS daemon
2016-12-23T18:06:08.006Z [ERROR] ipfs-daemon: Error: /media/dev/telescope/node_modules/node-webcrypto-ossl/build/Release/nodessl.node: undefined symbol: EVP_PKEY_decrypt
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:583:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/media/dev/telescope/node_modules/node-webcrypto-ossl/buildjs/native.js:2:14)
2016-12-23T18:06:43.892Z [DEBUG] ipfs-daemon: Shutting down...
2016-12-23T18:06:43.892Z [DEBUG] ipfs-daemon: IPFS daemon finished

happy christmas !

josselinchevalay avatar Dec 23 '16 18:12 josselinchevalay

@josselinchevalay Sorry for the delay! Not sure what's going on here. Are you packaging your Electron app in .asar? There's an open issue with .asar packaging that might be related/cause your error https://github.com/ipfs/js-ipfsd-ctl/issues/94.

If you are packaging it with asar, try without it. Let me know if that solves the issue.

haadcode avatar Jan 06 '17 20:01 haadcode

hey @haadcode,

how to know if package my application under asar. for i just use this command

LOG=debug IPFS_PATH=/tmp/somethingelse electron dist/main.js

if i use that how to disable that

regards,

josselinchevalay avatar Jan 06 '17 21:01 josselinchevalay

Hmm, ok so that wasn't the problem then. @josselinchevalay can you let us know what platform and OS version you're running? Which Node.js and npm version are you on?

@dignifiedquire, any ideas?

haadcode avatar Jan 07 '17 07:01 haadcode

hi,

os : Linux josselin-virtual-machine 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Node: v6.9.1

npm: 3.10.8 regards

josselinchevalay avatar Jan 07 '17 08:01 josselinchevalay

Thanks @josselinchevalay. I'm still unsure what the problem is, but might very well be related to https://github.com/ipfs/js-ipfs/issues/697#issuecomment-271269381 :/

"js-ipfs in the Node.js process of electron won't work because of incompatible crypto binding, it will work in the Browser process only since it uses WebCrypto directly."

haadcode avatar Jan 09 '17 12:01 haadcode

hi @haadcode

thx a lot. Could you share with an alternative method to use webCrypto. for example how to solve that into your chat projet =)

thx in avance.

Regards

josselinchevalay avatar Jan 09 '17 12:01 josselinchevalay

You can bypass that by putting everything in the renderer process of electron. See an example here https://github.com/haadcode/ipfs-daemon/blob/master/examples/browser/index.html. Hope this helps and let me know if you have any questions.

haadcode avatar Jan 09 '17 13:01 haadcode