Connecting to docker instance that's running multichain

+2 votes

So I have a multichain instance running on a centos docker image. My main machine is Windows 10 and I can connect to my multichain node and run commands using the multichain-cli application.

Now I am writing a Java application that uses the MultiChainJavaAPI and I am getting an exception thrown when I try to connect and run any commands. The exception I get is;

MultichainException [
                      object=code :401,
                      reason=message : Authorization Required,
                      message=null,
                      cause=null
]

 

I was originally working on an Ubuntu VM, and did not have a problem, but I wasn't running the multichain server on Docker. Now I am running it on windows I am facing this issue.

 

Here is CLI output from my terminals to show all is working.

Docker Image

[root@e91ecb9e1ebf recordz_chain]# multichaind recordz_chain -daemon

MultiChain 1.0.4 Daemon (latest protocol 10010)

Starting up node...

Other nodes can connect to this node using:
multichaind recordz_chain@172.17.0.3:6471

Listening for API requests on port 6470 (local only - see rpcallowip setting)

Node ready.

 

Windows Machine

PS C:\Software\multichain-windows-1.0.4> .\multichaind.exe recordz_chain -daemon

MultiChain 1.0.4 Daemon (latest protocol 10010)

Other nodes can connect to this node using:
multichaind recordz_chain@192.168.99.1:6471

This host has multiple IP addresses, so from some networks:
multichaind recordz_chain@192.168.56.1:6471
multichaind recordz_chain@192.168.0.10:6471

Listening for API requests on port 6470 (local only - see rpcallowip setting)

Node ready.

 

Command From Windows Terminal

PS C:\Software\multichain-windows-1.0.4> .\multichain-cli.exe recordz_chain getinfo

{"method":"getinfo","params":[],"id":1,"chain_name":"recordz_chain"}

{
    "version" : "1.0.4",
    "nodeversion" : 10004901,
    "protocolversion" : 10010,
    "chainname" : "recordz_chain",
    "description" : "MultiChain recordz_chain",
    "protocol" : "multichain",
    "port" : 6471,
    "setupblocks" : 60,
    "nodeaddress" : "recordz_chain@192.168.99.1:6471",
    "burnaddress" : "1XXXXXXXLnXXXXXXiTXXXXXXTFXXXXXXWF5mxB",
    "incomingpaused" : false,
    "miningpaused" : false,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "walletdbversion" : 2,
    "reindex" : false,
    "blocks" : 59,
    "timeoffset" : 0,
    "connections" : 2,
    "proxy" : "",
    "difficulty" : 0.00000006,
    "testnet" : false,
    "keypoololdest" : 1526140326,
    "keypoolsize" : 2,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00000000,
    "errors" : ""
}

 

I have the correct permissions setup and can communicate from my windows machine to my docker image, but when I am trying to run the application I get that error. I would have thought it was an issue with the API I am using, but I had this working before while on my Ubuntu VM, so I know its not the API.

I did find this answer - https://www.multichain.com/qa/2444/running-multichain-docker-unable-connect-external-service

I applied the solution of changing the defaulted password to a shorter one, just 'password' and restarted the multichain server and my windows connection to it. I also updated the password in my java application but still getting the same result.

I'm out of ideas now. Any help would be much appreciated

asked May 12, 2018 by doldy101

1 Answer

0 votes

The response from multichain-cli suggests that it is communicating with multichaind running directly under Windows, rather than that running within the Docker image. 

I would recommend first trying to get multichain-cli running against your version in Docker - it has various command-line options to choose the IP address, port, username and password. You may need to set up Docker to allowing incoming connections on that port, and also set up multichaind to allow API requests from something other than 127.0.0.1 (see the rpcallowip setting). Then you'll know all the networking stuff is working correctly. Then try again with that third party Java library.

answered May 13, 2018 by MultiChain
So I always thought that I had to have the server running locally and connect to that through my application. That is the reason why I have multichain running on my Windows machine. But yes when I am running my app I do communicate with multichaind on my Windows machine rather than the docker image. Would I be right in saying that I don't need multichaind running on my Windows machine?
I have docker already setup to allow both network and rpc ports. Thanks I will look into the rpcallowip command.
Indeed, there's no reason to run it under Windows as well. This is just a separate node and it's not the node you want to be communicating with.
...