Skip to content

Instantly share code, notes, and snippets.

@Leegorous
Created June 16, 2013 08:03
Show Gist options
  • Save Leegorous/5791336 to your computer and use it in GitHub Desktop.
Save Leegorous/5791336 to your computer and use it in GitHub Desktop.
If there are some requests you don't want to wait, just set the socket & connection timeout & no retry on error. Restlet 设置连接超时的方法。
Context ctx = new Context();
ctx.getParameters().add("socketTimeout", "200"); // http.socket.timeout
ctx.getParameters().add("socketConnectTimeoutMs", "100"); // http.connection.timeout
ClientResource client = new ClientResource(uri);
client.setNext(new Client(ctx, Protocol.HTTP));
client.setRetryOnError(false);
Representation entity = client.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment