IPC Connection – Why Can’t Connect by IPC in Nodejs

ipcnodejs

I have successfully run geth --rpc to test some functionality, but I need the personal API which according to this answer should be done by IPC.

When I run

geth --ipcapi "db,eth,net,web3,personal" --ipcpath /tmp/geth.ipc

This creates the ipc file and geth appears to otherwise start normally.

I have the following npm modules installed: web3 web3_extended web3_ipc

Then I run this on nodejs:

var web3_extended = require('web3_extended');

var options =
{
    host:     '/tmp/geth.ipc',
    ipc:      true,
    personal: true, 
    admin:    false,
    debug:    false
};

var web3 = web3_extended .create (options);

var coinbase = web3.eth.coinbase;

The last line gives me an HTML response which includes

Your browser sent a request that this server could not understand.

and

Apache/2.4.12 (Ubuntu) Server at localhost Port 80

That Apache line makes me think nodejs isn't even attempting to connect by IPC.

Why not? Or, what else is the problem?

Best Answer

Summary

Q: Why can't I connect by IPC? Why not? Or, what else is the problem?

A: From your HTML response message, it seems like your code is currently using the version of web3_extended that does not support the IPC protocol.



Details

Can you check that you are using tjade273/web3_extended and NOT The18thWarrior/web3_extended?

The first was forked from the second, and includes the IPC protocol handling. From tjade273/web3_extended/blob/index.js - lines 7 to 15:

function create(options) {
    if(options.ipc){
        var client = new net.Socket();
        web3.setProvider(new web3.providers.IpcProvider(options.host,client));
    }
    else{
        web3.setProvider(new web3.providers.HttpProvider(options.host));
    }
    if (options.personal) {

while the original code from The18thWarrior/web3_extended/blob/index.js - lines 6 to 9:

function create(options) {
    web3.setProvider(new web3.providers.HttpProvider(options.host));

    if (options.personal) {
Related Topic