4

I'm new to restlet, and trying to understand which HTTPS client option I should be using with android. Which HTTPS client option is most robust and stable for Android? I'm using restlet 2.1rc4 (and 2.1.0), and android 2.2. Unfortunately, changing the android version is not an option for me.

I think the possibilities are:

  1. Apache HttpClient (org.restlet.ext.httpclient)
  2. .net client (org.restlet.ext.net)
  3. Restlet internal client

I've had some success with org.restlet.ext.net, it works most of the time but I get various exceptions with "Communication Error (1001) with messages like "broken pipe", and also many cases of immediate return from a client request with a status of "null (-1)" without ever sending a request to the server. Maybe this is caused by bugs in the old android we are using, but I'm not really sure.

I tried to use the Apache client, but can't get HTTPS to work at all because it gives this exception: java.lang.IllegalStateException: Scheme 'https' not registered. The same code works on Windows with the Jave SE edition of org.restlet.ext.net.jar, but when I use the Android version of that same jar file it says https is not registered. I thought the Apache client supported HTTPS on android, but it isn't working for me.

I also tried the internal client, but that doesn't work at all either. I get the same 1001 error problem as Android RESTLet SSL Null Pointer. I tried this with restlet 2.1.0 and android 2.2.

My source code is basically like this (showing attempt to use Apache client):

context = new org.restlet.Context();
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
Engine.getInstance().getRegisteredClients().add(new org.restlet.ext.httpclient.HttpClientHelper(null));
client = new org.restlet.Client(context, org.restlet.data.Protocol.HTTPS);
context.setClientDispatcher(client);
ClientResource resource = new ClientResource(context, url);
resource.setEntityBuffering(true);
PojoResult result = resource.post(new PojoRequest, PojoResult.class);
Community
  • 1
  • 1
  • So far, it seems the answer is the restlet.ext.net client, because the other two choices don't work at all. But the ext.net client fails so often I can't use that either. – user1762069 Oct 30 '12 at 17:25
  • We found a way to (sort of) make the ext.net https client work on Android 2.2. Set a system property like this - System.setProperty("http.keepAlive", "false"); We didn't have to do this on Android 4.0.3. I never got the Apache client working, but didn't try too hard. – user1762069 Nov 07 '12 at 18:23

1 Answers1

0

The new 2.2 version of Restlet Framework has changed its internal HTTP/HTTPS client based on the HttpURLConnection (previously in org.restlet.ext.net extension). It is both more stable and lighter in term of size for org.restlet.jar.

Jerome Louvel
  • 2,882
  • 18
  • 19