MultiChain / multichain

Source code for multichaind, multichain-cli and multichain-util.
GNU General Public License v3.0
536 stars 259 forks source link

multichain-cli can't connect to the remote node #101

Closed easeev closed 4 years ago

easeev commented 5 years ago

I'm using Chainstack for network and node deployment.

I can interact with RPC via multiple methods described here (curl) and here (JavaScript and Python libraries) but not with multichain-cli.

I'm getting the error providing all required parameters:

$ ./multichain-cli nw-123-456-7 -rpcconnect=nd-123-456-789.p2pify.com -rpcport=80 -rpcuser=focused-koala -rpcpassword=shadow-sierra-sketch-edison-bonded-paging -rpcssl

MultiChain 2.0.2 RPC client

Interactive mode

nw-123-456-7: getinfo
{"method":"getinfo","params":[],"id":"57073710-1561637872","chain_name":"nw-123-456-7"}

error: no response from server

What could be the issue? Am I missing something?

gidgreen commented 5 years ago

You are using the -rpcssl command-line parameter and this requires the node itself to be running with the same parameter. Could that be the problem?

easeev commented 5 years ago

Similar result without this parameter:

$ ./multichain-cli nw-123-456-7 -rpcconnect=nd-123-456-789.p2pify.com -rpcport=80 -rpcuser=focused-koala -rpcpassword=shadow-sierra-sketch-edison-bonded-paging

MultiChain 2.0.2 RPC client

Interactive mode

nw-123-456-7: getinfo
{"method":"getinfo","params":[],"id":"81549545-1561687280","chain_name":"nw-123-456-7"}

error: couldn't parse reply from server

Chainstack JSON-RPC API is exposed through a dedicated ingress and not directly from the node. Perhaps that helps to understand the problem better.

gidgreen commented 5 years ago

Well yes, if you have some intermediate layer between the node and the incoming JSON-RPC request, that will probably explain the problem. You should be able to debug this by looking at the difference between the original response and the forwarded one.

easeev commented 5 years ago

Debugged a little. Looks like the multichain-cli request is sent with Host: 127.0.0.1 header which breaks the flow:

image

gidgreen commented 5 years ago

OK, thanks for working it out. This is a legitimate HTTP header so I think the intermediate layer needs to be able to process it, no?

easeev commented 5 years ago

Well, the intermediate layer is happy to process it if the value is correct and not 127.0.0.1 :)

See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html:

The Host field value MUST represent the naming authority of the origin server or gateway given by the original URL.

gidgreen commented 5 years ago

OK, understood, we'll look into it.

gidgreen commented 5 years ago

This should be fixed in the latest builds released today - please confirm.

easeev commented 4 years ago

It works, thanks!

$ ./multichain-cli nw-123-456-78 -rpcconnect=nd-123-456-789.p2pify.com -rpcport=443 -rpcuser=focused-koala -rpcpassword=shadow-sierra-sketch-edison-bonded-paging -rpcssl

MultiChain 2.0.3 RPC client

Interactive mode

nw-123-456-78: getinfo
{"method":"getinfo","params":[],"id":"85616894-1576762628","chain_name":"nw-123-456-78"}

{
    "version" : "2.0.3",
...
}