0

very simply I am following the web3j set up on the website, and when trying to get the latest version back to test it is connected to testrpc it throws a SocketException.

It says on the website that new HttpService() defaults to localhost:8545 which is what my testrpc is running on. I have also set the internet permission in the manifest.

//imports etc
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_screen);

    Web3j web3 = Web3jFactory.build(new HttpService());

    try {
        Web3ClientVersion clientVersion = 
            web3.web3ClientVersion().sendAsync().get();   //here is where thrown
        String clientVers = clientVersion.getWeb3ClientVersion();
        Log.d("hello", clientVers);

    }
    catch(InterruptedException e){
        e.printStackTrace();
    }
    catch(ExecutionException e){
        e.printStackTrace();   //throws as SocketException
    }
}
//other code that has nothing to do with web3j

Sorry if this is obvious any help would be amazing. Thanks.

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
B.K Lewis
  • 19
  • 1
  • 8
  • Where do you try to run? on your PC or mobile device? I think the problem can be in the fact the localhost at your running env is not the same localhost with environment of testrpc. For example, if you use Virtual Machine, localhost will point to that machine but testrpc is likely to be running on your host machine – Andrey Degtyaruk Jul 19 '17 at 10:52
  • @AndreyDegtyaruk You are correct that was my exact problem, thank you. – B.K Lewis Jul 20 '17 at 14:09

0 Answers0