Trying to connect via Java Client

+1 vote


I'm trying to make a connection with the multichain through a java client.

I tried to use both API as show below however, both show connection error refused.
I'm trying to connect through a client on the server, I tried to run the .jar on own server and the error messages were the same.

I also tried to follow the orientations of the following topics with the same doubts, but had no success. Below as well as station I view the files and params.dat multichain.conf


In server multichain.conf: (ip client)


And params.dat

anyone-can-connect = true              # Anyone can connect. Ignored if public-network=true.
anyone-can-send = true                 # Anyone can send. 
anyone-can-receive = true              # Anyone can receive. 

API BitcoinRPCClient

RPCClient c = new RPCClient();


public class RPCClient {
    private static final String COMMAND_GET_INFO = "getinfo";

    private JSONObject invokeRPC(String id, String method, List<String> params) {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        JSONObject json = new JSONObject();
        json.put("id", id);
        json.put("method", method);
        if (null != params) {
            JSONArray array = new JSONArray();
            json.put("params", params);
        JSONObject responseJsonObj = null;
        try {
            httpclient.getCredentialsProvider().setCredentials(new AuthScope("", 4368),
                    new UsernamePasswordCredentials("multichainrpc", "XYZ"));
            StringEntity myEntity = new StringEntity(json.toJSONString());
            HttpPost httppost = new HttpPost("");

            System.out.println("executing request" + httppost.getRequestLine());
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();

            if (entity != null) {
                System.out.println("Response content length: " + entity.getContentLength());
            JSONParser parser = new JSONParser();
            responseJsonObj = (JSONObject) parser.parse(EntityUtils.toString(entity));

      (... catch)

    public JSONObject getInfo() {
        JSONObject json = invokeRPC(UUID.randomUUID().toString(), COMMAND_GET_INFO, null);
        return (JSONObject)json.get("result");


API Bitcoin-JSON-RPC-Client​

public static void balance() throws BitcoinException {
        System.out.println(new BitcoinJSONRPCClient().getBalance());


asked Jan 12, 2016 by sola.carol
I can connect locally (in server) through it:

httpclient.getCredentialsProvider().setCredentials(new AuthScope("", 6716),
new UsernamePasswordCredentials("multichainrpc", "EsnbfGMskLXwNK524nBUnpERghF3PwNRwvFowVU2tZRY"));
StringEntity myEntity = new StringEntity(json.toJSONString());
HttpPost httppost = new HttpPost("http://multichainrpc:EsnbfGMskLXwNK524nBUnpERghF3PwNRwvFowVU2tZRY@");

but only have connection refused on the client

I try set in multichain.conf:


And I'm not sure if these commands can cause the restart of the chain

multichain-cli chainName stop
multichaind chainName -daemon

1 Answer

+1 vote
If you are in fact using proper credentials and made the changes to allow the RPC connection, you need to restart the node you want to connect to.

> multichain-cli chainName stop

> multichaind chainName --daemon

Thats the most help I can offer with your stacks setup. I have a working Ruby/Rails implementation running NGINX/Unicorn if you want?



Edit 1: Just saw your rpcallowip comment, it is wrong. It should just be the WAN IP of the server you are trying to connect from. if you need to find out.
answered Jan 12, 2016 by mreichardt
I tried restarting the node but errors continue.
also changed the rpcallowip to the server ip...

thank you, but I need a java api