2

I'm trying to connect to a local dogecoin server with jsonRPC.

The dogecoin daemon is launched with the following parameters:

dogecoin-qt -server -testnet -gen -debug -debugnet -printtoconsole -rpcuser=user -rpcpassword=user

The following Java code is used to connect to the server:

I'm using com.googlecode.jsonrpc4j.JsonRpcHttpClient

            JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://user:user@localhost:22555"));

        String response = "";
        client.invoke("getinfo()", response);
        System.out.println(response);

It just won't accept any credentials at all, I've tried setting them on the conf file, command-line, etc.

Server returned HTTP response code: 401 for URL: http://user:user@localhost:22555

Any ideas ?

1

Ok, it seems that for some reason I didn't read this essential part:

The easiest way to tell Java to use HTTP Basic authentication is to set a default Authenticator:

    final String rpcuser ="...";
  final String rpcpassword ="...";

  Authenticator.setDefault(new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
      }
  });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.