Java Client examples in developer's guide

+2 votes

I am trying to follow the developers guide to connect multichain via java client. There are 2 examples given (please check snapshot in below first link). "MultiChainJavaAPI" does not have main class while other "Multichain Client Java" (part-2) is giving 'connection refused' (see second link below). Plz hep?.



asked Jan 17, 2022 by Adnan UL Haque

1 Answer

+1 vote

A "connection refused" error is usually because the node is running on a different computer to the application, and the node has not been configured to allow incoming API requests from that other computer. Please search this Q&A forum for the word rpcallowip to see more information.

answered Jan 18, 2022 by MultiChain
Infact, my java client is on the same computer. Please advice accordingly.
Have you checked multichain is running by using the command-line, e.g. just to get the response from a command like getinfo?
I started working on java client after thoroughly checking multichain CLI functionality. You should again review my initial question whihc is specifically asking about some thing missing in official mutichain guidelines. Anyhow, issue is fixed and I am pasting here for other's to benefit ...

package multichain;

import multichain.command.CommandElt;
import multichain.command.CommandManager;
import multichain.command.RuntimeParameters;

public class dbt558 {
    public static void main(String[] args) {
        Object getInfo;

        RuntimeParameters Param=new RuntimeParameters();

        CommandManager CM=new CommandManager("localhost", "6756", "multichainrpc", "9UhZQQy8ZgaVZZbHtJkcXRVUdqzPAsLk9DPNCVAJy1UJ");

        try {


        } catch (Exception e) {


above java client is connected to following blockchian network.

$ ./multichaind tutchain -daemon
Other nodes can connect to this node using:
multichaind tutchain@

This host has multiple IP addresses, so from some networks:
multichaind tutchain@
multichaind tutchain@

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

Node ready.


user/password used in above java client from multichain.conf file (below printout)

adnan@MSI MINGW64 ~/AppData/Roaming/MultiChain/tutchain
$ cat multichain.conf

adnan@MSI MINGW64 ~/AppData/Roaming/MultiChain/tutchain
$ pwd

adnan@MSI MINGW64 ~/AppData/Roaming/MultiChain/tutchain
Thanks for the update and sharing the solutions. FYI these are third-party libraries so we are not so familiar with them.