Hi,
I've been having trouble to getting the apache http client working on
android.
I have the restlet.jar and ext.httpclient.jar on my class path and I am
adding the HttpClientHelper as per the instructions,
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null
));
I am creating my Client as a static so I can reuse it with
clientresource.setNext(client);
OK first thing learnt, dont initialise your client in the member declaration
because it will be created before the Engine has the client helper
registered with it. doh.
Second, you need to name the Apache client helper class when you create your
Client otherwise the engine just uses the first helper in its list that
matches the protocol which is the default http client.
That is not mentioned anywhere in the docs (that I can find)
So finally I got it using the apache http client but when I call get on a
uri with https I get the following error:
java.lang.IllegalStateException: Scheme 'https' not registered.
at
org.apache.http.conn.scheme.SchemeRegistry.getScheme(SchemeRegistry.java:80)
at
org.apache.http.impl.conn.DefaultHttpRoutePlanner.determineRoute(DefaultHttpRoutePlanner.java:107)
at
org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:565)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:292)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at
org.restlet.ext.httpclient.internal.HttpMethodCall.sendRequest(HttpMethodCall.java:331)
at
org.restlet.engine.http.adapter.ClientAdapter.commit(ClientAdapter.java:112)
at
org.restlet.engine.http.HttpClientHelper.handle(HttpClientHelper.java:110)
at org.restlet.Client.handle(Client.java:177)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.resource.ClientResource.handle(ClientResource.java:928)
at org.restlet.resource.ClientResource.handle(ClientResource.java:999)
at org.restlet.resource.ClientResource.handle(ClientResource.java:896)
at org.restlet.resource.ClientResource.handle(ClientResource.java:851)
at org.restlet.resource.ClientResource.handle(ClientResource.java:759)
at org.restlet.resource.ClientResource.get(ClientResource.java:492)
at
com.hullomail.android.messaging.webapi.HmBaseResource.get(HmBaseResource.java:148)
Any ideas how to fix that?
On top of that I am finding with both clients (I tried the apache one with
just http) that when I make multiple requests at the same time I see from
the logs that sometimes the client stops before one the request completes
and an exception is thrown. With the default client I get an 1002 Internal
connector error with the apache client i
get java.lang.IllegalStateException: Connection is not open.
I thought the client would stay running if I reused it? I am not explicitly
stopping it.
Stopping the HTTP client
Error while handling an HTTP client call
java.lang.IllegalStateException: Connection is not open
at
org.apache.http.impl.SocketHttpClientConnection.assertOpen(SocketHttpClientConnection.java:75)
at
org.apache.http.impl.AbstractHttpClientConnection.receiveResponseEntity(AbstractHttpClientConnection.java:191)
at
org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseEntity(AbstractClientConnAdapter.java:246)
at
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:281)
at
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:410)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at
org.restlet.ext.httpclient.internal.HttpMethodCall.sendRequest(HttpMethodCall.java:331)
at
org.restlet.engine.http.adapter.ClientAdapter.commit(ClientAdapter.java:112)
at
org.restlet.engine.http.HttpClientHelper.handle(HttpClientHelper.java:110)
at org.restlet.Client.handle(Client.java:177)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.resource.ClientResource.handle(ClientResource.java:928)
at org.restlet.resource.ClientResource.handle(ClientResource.java:896)
at org.restlet.resource.ClientResource.handle(ClientResource.java:851)
at org.restlet.resource.ClientResource.handle(ClientResource.java:759)
at org.restlet.resource.ClientResource.get(ClientResource.java:492)
thanks in advance
Chris
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2702307