0

I'm using Eclipse to (try to) build an Android client to get reuse a restlet service I developed using GAE and GWT.

My service is running at

    http://127.0.0.1:8888/abc/audits  

I can test this by going directly to this url, and by using my GWT client - both work.

However, the following code returns a communication error

    private AuditsResource resource;
    private Audits audits;

    ClientResource cr = new ClientResource("http://127.0.0.1:8888/abc/audits");
    resource = cr.wrap(AuditsResource.class);
    try {
    // Get the remote contact
     audits = resource.retrieve();
    // The task is over, let the parent conclude.
    handler.sendEmptyMessage(0);
    } catch (Exception e) {
        Message msg = Message.obtain(handler, 2);
        Bundle data = new Bundle();
        data.putString("msg", "Cannot get the contact due to: "
            + e.getMessage());
        msg.setData(data);
        handler.sendMessage(msg);
    }

I have no idea where to look next. I've instrumented the server implementation of AuditsResource, and it is never touched (by the Android application).

The AuditsResource class has one method, to keep things simple for now

    @Get
    public Audits retrieve();

2 Answers2

0

It appears the problem is that the Andriod Emulator cannot connect to either 127.0.0.1 or 10.0.2.2. The solution is to use your PC's IP address.

0

I am able to connect from Android to my local Google App Engine through Android/Restlet using 10.0.2.2 instead of localhost.

user229044
  • 232,980
  • 40
  • 330
  • 338
Richard Berger
  • 247
  • 2
  • 11