Connect via RPC to multichain node

+2 votes

Hello

I'm having trouble connecting to multichain-node for RPC request.  Terminal requests work just fine : 

multichain-cli PecheMLC -rpcport=4790 -rpcuser=multichainrpc -rpcpassword=3ZnqXHcc3LZ9Q9CZo3xpGB4ppNg8nvS4HtifT7oZfsyK // get me all access 

Yet,  from node file embeded in firebase function file, I keep having :

{ Error: connect ECONNREFUSED 127.0.0.1:4790
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 4790 }

 

here is my code : 

//

exports.initMultiChain = functions.https.onRequest((req,res) => {

  let multichain = require("multichain-node")({
      port: 4790, // got this from params.dat
      host: '127.0.0.1', // local
      user: 'multichainrpc',
      pass: '3ZnqXHcc3LZ9Q9CZo3xpGB4ppNg8nvS4HtifT7oZfsyK'
  });
  multichain.getInfo(function(e, info){
  if(e){ console.log(e);}
  res.send(info)
  res.end("done")
  });

})

and multichain.conf : 

rpcuser=multichainrpc
rpcpassword=3ZnqXHcc3LZ9Q9CZo3xpGB4ppNg8nvS4HtifT7oZfsyK

 Many thanks in advance if you  have clue on this :)

 

asked Aug 16, 2017 by Geoffroy

1 Answer

0 votes
We're not familiar with this Firebase library, but the most likely explanation is that the method of HTTP authentication is not what MultiChain is expecting. Here are some notes:

Authentication is implemented using HTTP basic authentication. RPC HTTP requests must include a Content-Type header set to text/plain and a Content-Length header set to the size of the request body.
answered Aug 16, 2017 by MultiChain
...