Title: Can't connect to Bitcoin wallet with JSON-RPC
Post by: devnikor on March 02, 2014, 03:59:52 PM
I'm trying to connect to Bitcoin wallet from Java. But i get network exception: Server redirected too many times. I would be very glad if someone helps me understand. Here's my code: public static void SetupRPC() { CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication ("admin", "admin".toCharArray()); } });
URL serverURL = null; try { serverURL = new URL("http://127.0.0.1:44843"); } catch (MalformedURLException e) { System.err.println(e.getMessage()); }
JSONRPC2Session mySession = new JSONRPC2Session(serverURL); String method = "getinfo"; int requestID = 0; JSONRPC2Request request = new JSONRPC2Request(method, requestID);
// Send request JSONRPC2Response response = null;
try { response = mySession.send(request); } catch (JSONRPC2SessionException e) { System.err.println(e.getMessage()); }
if (response.indicatesSuccess()) System.out.println(response.getResult()); else System.out.println(response.getError().getMessage()); } And .conf file: rpcuser="admin" rpcpassword="admin" rpcallowip=* rpcport=44843 server=1 daemon=1 listen=1 rpcconnect=127.0.0.1
Title: Re: Can't connect to Bitcoin wallet with JSON-RPC
Post by: Voltage2 on March 03, 2014, 03:24:57 AM
I have already posted this on Stackoverflow, but if other forum members have problems with this, here is the link (http://stackoverflow.com/questions/22126326/cant-connect-to-bitcoin-wallet-with-json-rpc/22138019#22138019")
|