Bitcoin Forum
August 19, 2018, 11:37:56 AM *
News: Latest stable version of Bitcoin Core: 0.16.2  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Can't connect to Bitcoin wallet with JSON-RPC  (Read 761 times)
devnikor
Newbie
*
Offline Offline

Activity: 13
Merit: 0


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

Posts: 1534678676

View Profile Personal Message (Offline)

Ignore
1534678676
Reply with quote  #2

1534678676
Report to moderator
1534678676
Hero Member
*
Offline Offline

Posts: 1534678676

View Profile Personal Message (Offline)

Ignore
1534678676
Reply with quote  #2

1534678676
Report to moderator
BOUNTY PORTALS
BLOG
WHERE BOUNTY MANAGEMENT
MEETS AUTOMATION
SIGNATURE CAMPAIGNS
TWITTER
FACEBOOK
MEDIA CAMPAIGNS
AND MORE!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1534678676
Hero Member
*
Offline Offline

Posts: 1534678676

View Profile Personal Message (Offline)

Ignore
1534678676
Reply with quote  #2

1534678676
Report to moderator
Voltage2
Newbie
*
Offline Offline

Activity: 11
Merit: 0


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!