Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

eleactron main.js try to use ipfs daemon #10

Open
josselinchevalay opened this issue Dec 18, 2016 · 9 comments
Open

eleactron main.js try to use ipfs daemon #10

josselinchevalay opened this issue Dec 18, 2016 · 9 comments

Comments

@josselinchevalay
Copy link

josselinchevalay commented Dec 18, 2016

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
Copy link
Owner

@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
Copy link
Author

josselinchevalay commented Dec 23, 2016

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
Copy link
Owner

haadcode commented Jan 6, 2017

@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 ipfs/js-ipfsd-ctl#94.

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

@josselinchevalay
Copy link
Author

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
Copy link
Owner

haadcode commented Jan 7, 2017

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
Copy link
Author

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
Copy link
Owner

haadcode commented Jan 9, 2017

Thanks @josselinchevalay. I'm still unsure what the problem is, but might very well be related to ipfs/js-ipfs#697 (comment) :/

"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
Copy link
Author

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
Copy link
Owner

haadcode commented Jan 9, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants