I followed the instructions given in below page but still getting the error.
http://bitcoin.stackexchange.com/questions/7529/how-to-communicate-between-java-and-bitcoind
When I started a node on one machine it gets successfully started and give the message as
New users can connect to this blockchain using
multichaind chain2@192.168.136.128:6795
Now from another machine using java code, i tried to connect with using below sample code but it gives connection timeout message. Also in below code, I don't what credential i have to provide while initializing UsernamePasswordCredentials().
DefaultHttpClient httpclient = new DefaultHttpClient();
JSONObject json = new JSONObject();
json.put("id", "chain2");
json.put("method", "getinfo");
List<String> params = new ArrayList<String>()
if (null != params) {
JSONArray array = new JSONArray();
array.addAll(params);
json.put("params", params);
}
JSONObject responseJsonObj = null;
try {
httpclient.getCredentialsProvider().setCredentials(new AuthScope("192.168.136.128", 6795),
new UsernamePasswordCredentials("", ""));
StringEntity myEntity = new StringEntity(json.toJSONString());
System.out.println(json.toString());
HttpPost httppost = new HttpPost("http://192.168.136.128:6795");
httppost.setEntity(myEntity);
System.out.println("executing request" + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
// System.out.println(EntityUtils.toString(entity));
}
JSONParser parser = new JSONParser();
responseJsonObj = (JSONObject) parser.parse(EntityUtils.toString(entity));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}