haadcode / ipfs-daemon

Get a running IPFS daemon quickly and easily
26 stars 7 forks source link

eleactron main.js try to use ipfs daemon #10

Open josselinchevalay opened 7 years ago

josselinchevalay commented 7 years ago

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 !

haadcode commented 7 years ago

@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.

josselinchevalay commented 7 years ago

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 !

haadcode commented 7 years ago

@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.

josselinchevalay commented 7 years ago

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,

haadcode commented 7 years ago

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?

josselinchevalay commented 7 years ago

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

haadcode commented 7 years ago

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."

josselinchevalay commented 7 years ago

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

haadcode commented 7 years ago

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.