Reputation: 11
How does one change the timeout on a Restlet Client get()
?
All I've have been able to find is the obsolete SetConnectTimeout()
. I tried context.getParameters().add ( "socketTimeout", "1000" );
with no success.
Upvotes: 1
Views: 1856
Reputation: 866
Basically, this is done by configuring the client connector (class org.restlet.Client
):
client.context.getParameters().add ( "parameter", "value" );
I see two distinct contexts and thus two ways to get the client connector.
You are running your client calls inside a org.restlet.Component
container
In this case, configure the common client connector hosted by the component:
Component c = new Component();
Client client = c.getClients().add(Protocol.HTTP);
client.getContext().getParameters().add ( "parameter", "value" );
You are not running your client calls inside a org.restlet.Component
container
In this case, instantiate manually the client connector and set it to the ClientResource
Client client = new Client(new Context(), Protocol.HTTP);
client.getContext().getParameters().add ( "parameter", "value" );
ClientResource cr = new ClientResource("http://example.com");
cr.setNext(client);
To conclude with, the list of available parameters to be set depends on the kind of client connector you are using (internal connector, based on httpclient
, etc)
You can have a look at this page http://restlet.com/learn/guide/2.2/core/base/connectors/.
Upvotes: 2