Curl RPC : Empty response from server. CLI works

+1 vote
Hi, am trying to issue a simple RPC command using curl:

curl --user rpc:rpc --data '{"jsonrpc":"1.0", "method":"getinfo", "params":[], "id":"4"}' -H 'content-type: text/plain;' http://10.0.7.4:9701/

 

That results in:

curl: (52) Empty reply from server

multichain-cli for this chain works fine and i can issue commands in interactive mode. What am i missing here? I've tried various combinations of using --data  and --data-binary, tried different methods and also tried using localhost .

My command to start the chain is:

multichaind pd2 -rpcallowip=10.0.7.4
asked Jul 18, 2017 by YSK

1 Answer

0 votes
 
Best answer

First it may be that the username/password are wrong and don't match those in the blockchain's multichain.conf file – I'm not sure if the values you placed above are a placeholder or that's what you really entered.

Second if you use the help getinfo command in multichain-cli you will see an example of curl usage.

Lastly if you run curl with the -vvvv option you'll see much more details about the process and what's going wrong.

answered Jul 19, 2017 by MultiChain
Interesting--the help getinfo  was helpful. The issue was that i was using the wrong port for JSON RPC. The correct port is 9700 whereas, the reported port on multichaind and 'getinfo' is 9701. Is this by design that the curl/http port is one minus the  reported port?
There are two different ports - for nodes to connect to each other, and for API calls. The port reported by multichaind on the command line is for other peers to connect.
I am using CLOUD9 IDE. i am writing this command curl --user multichainrpc:CYeoxgR14cyptsTavbvcPXnLtcJULfRBaCj4DChfDEf8 --data '{"jsonrpc":"1.0", "method":"getinfo", "params":[], "id":"4"}' -H 'content-type: text/plain;' http://localhost:6808 and also used this ip 172.17.0.85 but could not get any response. Do i have to whitelist my ip ? please guide ?
Is 6808 the port for RPC or the port for peer-to-peer connections?
...