Reputation: 17439
I'm using Retrofit for calling REST web API (a GET request).
The RestAdapter is:
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(strEndpoint)
.build();
and this works fine.
Sometimes, however, the http GET is a bit slow, so the Callback that I have implemented in the failure(RetrofitError err)
returns a error, like:
10-02 16:47:15.279: I/ERROR(16413): error downloading data: failed to connect to myserver.privete.com (port 80) after 15000ms
However, this error appens only if I use wifi connection.
So I have decide to try changing the connection timeout, adding a custom OkClient, using the library OkHttp
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(60, TimeUnit.SECONDS);
client.setReadTimeout(60, TimeUnit.SECONDS);
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(Parameters.production ? Parameters.productionEndPoint : Parameters.testEndPoint)
.setClient(new OkClient(client))
.build();
But this generates IMMEDIATELY this error:
10-02 16:42:38.489: I/ERROR(14259): error downloading data: com.squareup.okhttp.OkHttpClient.open
I versions I used are shown below:
Retrofit: 1.6.1
okhttp: 2.0.0
okhttp-urlconnection: 1.6.0
EDIT:
I also tried with okhttp-urlconnection 2.0.0
Upvotes: 0
Views: 932
Reputation: 47
You probably need okhttp-urlconnection 2.0.0.
Unrelated to this, but for any future problems you can get better debug output by using
.setLogLevel(RestAdapter.LogLevel.FULL)
Upvotes: 1