cannot make a new request because the previous response is still open: please call response.close()
See original GitHub issueI am using retrofit2 and tried to hit the call.
But I am getting the error as cannot make a new request because the previous response is still open: please call response.close().
My request is like
serviceRequestTypesResponseCall.enqueue(new RetrofitCallback<ServiceRequestTypesResponse>(retrofit) {
@Override
public void onResponse(RetrofitResult<ServiceRequestTypesResponse> result) {
// get url from response and enqueue nested call
detailedServiceRequestTypeCall.enqueue(new RetrofitCallback<DetailedServiceRequestType>(retrofit) {
@Override
public void onResponse(RetrofitResult<DetailedServiceRequestType> result) {
// this is being reached when cancelled
}
@Override
public void onFailure(RetrofitResult<DetailedServiceRequestType> error) {
// do something
}
});
}
@Override
public void onFailure(RetrofitResult<ServiceRequestTypesResponse> error) {
// do something
}
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Is there a problem doing another API call inside interceptor in ...
IllegalStateException: cannot make a new request because the previous response is still open: please call response.close().
Read more >This is a nice implementation of the AuthInterceptor, however ...
IllegalStateException: cannot make a new request because the previous response is still open: please call response.close().
Read more >okhttp3.Response.close java code examples - Tabnine
public void onResponse(Call call, Response response) throws IOException ... Request request = requestBuilder .delete() .build(); execute(request).close(); }.
Read more >While tring to download file from onedrive through graph api ...
IllegalStateException: cannot make a new request because the previous response is still open: please call response.close() at ...
Read more >Using OkHttp | CodePath Android Cliffnotes
Response response = client.newCall(request).execute();. Because Android disallows network calls on the main thread, you can only make synchronous calls if ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I don’t have a solution but an interesting hint to this issue. We’ve got that error as well but it came after a retrofit update.
We updated from 2.5.0 to 2.9.0. With 2.9.0 we have this exception, with 2.5.0 everything works fine. Can you acknowledge that its exception does not occur with this version?
We are using retrofit2 2.9.0v. We are facing this issue suddenly but not able to reproduce. we found this crash in Crashlytics. should we close the response manually?
Or any other solution for this issue?
Fatal Exception: java.lang.IllegalStateException cannot make a new request because the previous response is still open: please call response.close()
okhttp3.internal.connection.Transmitter.newExchange (Transmitter.java:164) okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:41) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:117) okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:94) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:117) okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:88) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:117) ai.haptik.android.sdk.common.OkHttpClientFactory$1.intercept (OkHttpClientFactory.java:101) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:117) ai.haptik.android.sdk.common.a.intercept (a.java:30) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:142) okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:117) okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:229) okhttp3.RealCall$AsyncCall.execute (RealCall.java:172) okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) java.lang.Thread.run (Thread.java:923)