Why does command "CommandElt.GETPEERINFO" in MultiChainJavaAPI always return null?

+1 vote

I have two Multichain instances up and running in two different machine nodes. And, second node (it is virtual machine) is connected to the first one. I am developing a Java Application using MultiChainJavaApi in Eclipse IDE. The problem is that, I am able to run "getpeerinfo" command using command line, but the same command always returns null when I use MultiChainJavaApi command <CommandElt.GETPEERINFO> in an application. 

Please find below code snippet 

Object connectedNodes = null;

connectedNodes = commandManager.invoke(CommandElt.GETPEERINFO);

The below code snippet is a commandManager configuration

@Bean

public CommandManager commandManager() {

return new CommandManager("localhost", "9556", "multichainrpc","4sjwH****************************");

}

 Any solution and suggestion is highly appreciated.

asked Jan 6, 2020 by nmunjpara

3 Answers

0 votes

What happens when you run other commands? It may be that the problem is with this specific command only (in which case you should contact the Java API developer). Or it may be with the entire JSON-RPC connection, in which case something is probably configured incorrectly – perhaps the correct IP address needs to be used and the rpcallowip setting needs to be set for the MultiChain node.

answered Jan 6, 2020 by MultiChain
Sure. I will try to contact Java API developer, too.

Other commands works fine but I haven't tested all of them. I have encountered "getpeerinfo" and "getnetworkinfo" commands not working even though they returns proper output using cmd.

JSON-RPC connection is fine as I have tested by creating two commandManager objects of both the nodes as shown below,

@Bean
    public CommandManager commandManagerOne() {
        return new CommandManager("localhost", "9720", "multichainrpc","2a62yQ8owXaC5TAfbg3Z**********************");               
    }
   
    @Bean
    public CommandManager commandManagerTwo() {
        return new CommandManager("192.168.69.10", "9720", "multichainrpc","Aaswoe9scKEyXowjkPi3***********************");               
    }

And ran "getaddresses" command which has given valid output,

nodeOne = commandManagerOne.invoke(CommandElt.GETADDRESSES);
nodeTwo = commandManagerTwo.invoke(CommandElt.GETADDRESSES);

Also, I was able to connect to the second node only when "rpcallowip" setting have been applied.

I have no idea why above two commands does not work. Eventhough "getnetworkinfo" is supposed to give current node's network info, it is giving "NULL" all the time.

Other than above let me know if any other configuration/settings needs to be done.

Thanks.
If all commands are working through multichain-cli, and some commands are working and some not through this Java library, then it will definitely be an issue with the library.
0 votes

Hi,

MultichainJavaAPI is an Open Source Java API : https://github.com/SimplyUb/MultiChainJavaAPI

Multichain refers the API but the API is completly developped independently with no direct link with Multichain developpment team. You should ask API question directly on github space.

To answer to some questions/comments :

- In my side getperrinfo with multichain-cli call (under windows) doesn't answer anything :

{"method":"getpeerinfo","params":[],"id":"87472457-1579686599","chain_name":"ABC001"}

[
]

The API answers null, maybe it could be an empty list. No return was done before for one or the other;

- getnetworkinfo is still not implemented. No one asked for it before. MultichainJavaAPI is an Open Source API, don't hesitate to ask for fonctionnalities or, more than that, to contribute;

- usually to test created Blockchain well being, I commonly use : CommandElt.GETINFO

answered Jan 22, 2020 by Ub
0 votes

I'm using the same Java API for multichain development but, getpeerinfo working fine in my case.
Whoever has developed this MultiChainJavaAPI, did one mistake in getnetworkinfo command.

In this API code, NetworkInfo class is used to hold the output of getnetworkinfo command.
I have found that inside NetworkInfo class there is another child used called NetworkInfoNetwork.

So we have Issue with this NetworkInfoNetwork class.
Here we have below four attributes:

String name = null;
Long limited = null;
Long reachable = null;
String proxy = null;

We have issue with Long variable, because the actual value return by system is Boolean instead of long.
Once you replace those Long attribute with Boolean then it will be working fine.
I'll do the same in my API code and now there is no issue with getnetworkinfo command.

answered Feb 14, 2020 by Nikunj Dhameliya
...