Connect rpc to a node in my ubuntu server from local machine using node js

+2 votes
I'm trying to connect to a node running on an ubuntu server from my local machine using node js and gives me this error

        throw err;
        ^

Error: getaddrinfo EAI_FAIL chain-test-1@34.229.191.106:7221
    at Object.exports._errnoException (util.js:1018:11)
    at errnoException (dns.js:33:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

 

My code is:

let multichain = require("multichain-node")({
    port: 7221,
    host: 'chain-test-1@34.229.191.106',
    user: "multichainrpc",
    pass: "579fZMvSHLbdnbmg253CAm8Tmvs8c7uZz7WEHH6H1kJ4"
});

multichain.getInfo((err, info) => {
    if(err){
        throw err;
    }
    console.log(info);
})
asked Aug 22, 2017 by Luis Acerv
reopened Aug 23, 2017

1 Answer

0 votes

We didn't write this library, but I'm guessing the host should be just 34.229.191.106 rather than the full node address.

answered Aug 23, 2017 by MultiChain
I just made it work, but once again gives me this error

Error: socket hang up
    at createHangUpError (_http_client.js:253:15)
    at Socket.socketOnEnd (_http_client.js:345:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
Have you set the rpcallowip parameter on the server to allow non-local incoming API connections?
In multichain gonf? rpcallowip=0.0.0.0/0 I have set up, the node is located in aws, I also opened the port from getInfo in the security gruops
I clone the multichain-node example from github and replaced the credentials and I get this error:
  throw new assert.AssertionError({
  ^
AssertionError: Could not get info
    at multichain.getInfo (C:\Users\nacho\multichain-node\test\test.js:45:9)
    at client.call (C:\Users\nacho\multichain-node\lib\rpccall.js:40:17)
    at ClientRequest.req.on (C:\Users\nacho\multichain-node\lib\client.js:46:17)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketOnEnd (_http_client.js:345:9)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
Please try telnet to the rpc port on the MultiChain node server, to see if it can connect. This will help you determine whether it's an issue with the MultiChain setup, or access from the multichain-node library.
...