Author

Topic: Can't connect to Bitcoin wallet with JSON-RPC (Read 861 times)

newbie
Activity: 11
Merit: 0
I have already posted this on Stackoverflow, but if other forum members have problems with this, here is the link
newbie
Activity: 13
Merit: 0
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:
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:
Code:
rpcuser="admin"
rpcpassword="admin"
rpcallowip=*
rpcport=44843
server=1
daemon=1
listen=1
rpcconnect=127.0.0.1
Jump to: