Bitcoin Forum
December 16, 2017, 11:14:14 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Can't connect to Bitcoin wallet with JSON-RPC  (Read 754 times)
devnikor
Newbie
*
Offline Offline

Activity: 13


View Profile
March 02, 2014, 03:59:52 PM
 #1

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
1513422854
Hero Member
*
Offline Offline

Posts: 1513422854

View Profile Personal Message (Offline)

Ignore
1513422854
Reply with quote  #2

1513422854
Report to moderator
1513422854
Hero Member
*
Offline Offline

Posts: 1513422854

View Profile Personal Message (Offline)

Ignore
1513422854
Reply with quote  #2

1513422854
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1513422854
Hero Member
*
Offline Offline

Posts: 1513422854

View Profile Personal Message (Offline)

Ignore
1513422854
Reply with quote  #2

1513422854
Report to moderator
1513422854
Hero Member
*
Offline Offline

Posts: 1513422854

View Profile Personal Message (Offline)

Ignore
1513422854
Reply with quote  #2

1513422854
Report to moderator
Voltage2
Newbie
*
Offline Offline

Activity: 11


View Profile
March 03, 2014, 03:24:57 AM
 #2

I have already posted this on Stackoverflow, but if other forum members have problems with this, here is the link
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!