When building the endpoint, specify the connection and read timeouts in the HttpRequestInitializer. For example, in this case, 20 and 10 seconds, 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);
}
});
source
share