question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot make a new request because the previous response is still open: please call response.close()

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
Votocommented, Mar 8, 2021

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?

4reactions
Deepanr20commented, Oct 7, 2021

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found