With Android, how do I set the maximum deadline for a Cloud Endpoint request?
android, google-app-engine, google-cloud-endpoints
Solution
When building the endpoint, specify a connect and read timeout in HttpRequestInitializer. For example, in this case 20 and 10 secs respectively.
SomeEndpoint.Builder endpointBuilder = new SomeEndpoint.Builder(
AndroidHttp.newCompatibleTransport(),
new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) {
httpRequest.setConnectTimeout(20 * 1000);
httpRequest.setReadTimeout(10 * 1000);
}
});
Problem
When making a `ClientEndpoint` API request from an Android app to an App-Engine service, how do I set a deadline/timeout for the `execute()` action? I'm looking for something like: ``` Foo foo = endpoint.getSomething(id) .setDeadline(2000/*ms*/) .execute(); ```