I'm trying to do simple JSON-RPC call to 'getinfo' method with no parameters with Apache Http-components HttpClient, but all I got is:
org.apache.http.NoHttpResponseException: 127.0.0.1:33002 failed to respond
My JSON RPC request is:
{ "method": "getinfo", "params": [], "id": 1}
And the code is:
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope( "localhost" , 33002 ) ,
new UsernamePasswordCredentials( "loginxxx" , "passxxx" ) );
CloseableHttpClient client = HttpClients.custom()
.setDefaultCredentialsProvider( credsProvider )
.build();
HttpPost request = new HttpPost( "http://127.0.0.1:33002/jsonrpc" );
request.setEntity( new StringEntity( "{\"method\":\"getinfo\",\"params\":[],\"id\":1}" ) );
HttpResponse response = client.execute( request );
Why server is not responsing? How can I improve my JSON-RPC request?
Full trace log from apache: http://pastebin.com/K2HTZ4nR
Edit: changing both hostnames to 127.0.0.1 or both to localhost doesn't helps. Also putting id in \"1\" doesn't helps. EntityUtils.consume
also doesn't helps. Removing /jsonrpc
from URL
also.
The calling code is ok. This issue comes when you configure port
setting instead of rpcport
in Bitcoin .
So I was connecting to some other service in Bitcoin wallet (propably just a bitcoin network service p2p server).