Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Restlet HTTPS

When trying to get some data on my android client from my webservice (running on app-engine) with this code

ClientResource cr = new ClientResource("https://myapp.appspot.com/restlet/service/");
IServiceResource res = cr.wrap(IServiceResource.class);
m_Services = res.getServices();

I get this error:

05-20 08:30:15.406: ERROR/AndroidRuntime(31767): Caused by: Communication Error (1001) - Could not change the mode after the initial handshake has begun.

i have the org.restlet.ext.ssl.jar for the https-support and i am using this line to add the client

Engine.getInstance().getRegisteredClients().add(new HttpsClientHelper(null));

this is the closest i have come to getting https:// calls to work since i moved up to restlet 2.1m4 (moved because i was in need of entityBuffering..)

Any ideas? Any other information i need to share?

like image 498
Fredrik Widerberg Avatar asked Oct 25 '22 11:10

Fredrik Widerberg


1 Answers

Got it working. Changed HttpClient to org.restlet.ext.net.

On Android, you are told to do this to change the client

Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null));

However nothing changes by doing so, instead, i had success with

Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null));

This solves the issu(be sure to have org.restlet.ext.ssl in your build path aswell). This also solves other issues such as the "Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it."

like image 107
Fredrik Widerberg Avatar answered Oct 27 '22 09:10

Fredrik Widerberg