0
我使用的是改造2.0,下面的代碼將記錄:(2.0)的改型調用內部改造調用導致超時異常
"insertListingImages, SocketOutOfTimeException:TimeOut timeout"
。
爲什麼會造成超時異常?我該如何解決它?奇怪的是,如果翻新呼叫,hi()
不在改造呼叫中,insertListingImages()
一切都會正常工作。
retrofit = new Retrofit.Builder()
.baseUrl("http://IP_ADRESS/")
.addConverterFactory(GsonConverterFactory.create())
.build().create(DatabaseInterface.class);
retrofit.insertListingImages(imageListingRequest).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
Log.d("insertListingImages", "Success");
retrofit.hi().enqueue(new Callback<Void>(){
@Override
public void onResponse(Call<Void> call, Response<Void> response){
Log.d("hiTest", "Success");
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
Log.d("hiTest", "fail: " + t.toString() + " " + t.getMessage());
}
});
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
Log.d("insertListingImages", "fail: " + t.toString() + " " + t.getMessage());
}
});
我會試試這個,當我cnan;但爲什麼會發生超時? –
閱讀此https://stackoverflow.com/questions/30767460/okhttp-retrofit-default-timeout – Nithinlal