[BUG] Hitting the exception 'cannot make a new request because the previous response is still open: please call response.close()'
See original GitHub issueDescribe the bug While using the Azure java SDK to make API calls to Azure, we faced this issue. After making a few number of requests to the list storage accounts API call, we hit the exception java.lang.RuntimeException: java.io.IOException: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
Exception or Stack Trace
java.lang.RuntimeException: java.io.IOException: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
at rx.exceptions.Exceptions.propagate(Exceptions.java:57) ~[sd-0.1.jar:?]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:463) ~[sd-0.1.jar:?]
at rx.observables.BlockingObservable.single(BlockingObservable.java:340) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.compute.implementation.VirtualMachinesInner$61.nextPage(VirtualMachinesInner.java:1749) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter$2.nextPage(PagedListConverter.java:70) ~[sd-0.1.jar:?]
at com.microsoft.azure.PagedList.cachePage(PagedList.java:62) ~[sd-0.1.jar:?]
at com.microsoft.azure.PagedList.<init>(PagedList.java:56) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter$2.<init>(PagedListConverter.java:67) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter.convert(PagedListConverter.java:67) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl.wrapList(ReadableWrappersImpl.java:43) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl.list(TopLevelModifiableResourcesImpl.java:118) ~[sd-0.1.jar:?]
Caused by: java.io.IOException: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
at com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor.intercept(ResourceManagerThrottlingInterceptor.java:110) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor.intercept(ProviderRegistrationInterceptor.java:43) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.BaseUrlHandler.intercept(BaseUrlHandler.java:43) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.RequestIdHeaderInterceptor.intercept(RequestIdHeaderInterceptor.java:29) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221) ~[sd-0.1.jar:?]
at okhttp3.RealCall.execute(RealCall.java:81) ~[sd-0.1.jar:?]
at retrofit2.OkHttpCall.execute(OkHttpCall.java:186) ~[sd-0.1.jar:?]
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:40) ~[sd-0.1.jar:?]
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:24) ~[sd-0.1.jar:?]
at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[sd-0.1.jar:?]
at rx.Observable.subscribe(Observable.java:10423) ~[sd-0.1.jar:?]
at rx.Observable.subscribe(Observable.java:10390) ~[sd-0.1.jar:?]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:443) ~[sd-0.1.jar:?]
... 65 more
Caused by: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:164) ~[sd-0.1.jar:?]
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.retry.RetryHandler.intercept(RetryHandler.java:75) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.CustomHeadersInterceptor.intercept(CustomHeadersInterceptor.java:140) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.UserAgentInterceptor.intercept(UserAgentInterceptor.java:83) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.azure.credentials.AzureTokenCredentialsInterceptor.intercept(AzureTokenCredentialsInterceptor.java:40) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor.intercept(ResourceManagerThrottlingInterceptor.java:108) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor.intercept(ProviderRegistrationInterceptor.java:43) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.BaseUrlHandler.intercept(BaseUrlHandler.java:43) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at com.microsoft.rest.interceptors.RequestIdHeaderInterceptor.intercept(RequestIdHeaderInterceptor.java:29) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) ~[sd-0.1.jar:?]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) ~[sd-0.1.jar:?]
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221) ~[sd-0.1.jar:?]
at okhttp3.RealCall.execute(RealCall.java:81) ~[sd-0.1.jar:?]
at retrofit2.OkHttpCall.execute(OkHttpCall.java:186) ~[sd-0.1.jar:?]
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:40) ~[sd-0.1.jar:?]
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:24) ~[sd-0.1.jar:?]
at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[sd-0.1.jar:?]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[sd-0.1.jar:?]
at rx.Observable.subscribe(Observable.java:10423) ~[sd-0.1.jar:?]
at rx.Observable.subscribe(Observable.java:10390) ~[sd-0.1.jar:?]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:443) ~[sd-0.1.jar:?]
... 65 more
To Reproduce Created a azure client and called the list storage accounts API call 100 times using the following snippet:
new ApplicationTokenCredentials(
clientId,
tenantId,
clientSecret,
azureEnvironment
)
val azure =
Azure.configure.withReadTimeout(timeout,TimeUnit.MILLISECONDS).withConnectionTimeout(timeout,TimeUnit.MILLISECONDS).authenticate(appCredentials).withSubscription("<subscriptionId>")
for (i <- 1 to 100) {
println(i)
azure.storageAccounts().list()
}
And this fails with the following :
1
<..>
<..>
<..>
99
2019-11-29T15:53:58.237+0530 ERROR <.main> [compute.AzureComputeClientImpl] An unknown exception is thrown. Will not be retrying.
java.lang.RuntimeException: java.io.IOException: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
at rx.exceptions.Exceptions.propagate(Exceptions.java:57) ~[generated-intellij-deps.jar:?]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:463) ~[generated-intellij-deps.jar:?]
at rx.observables.BlockingObservable.single(BlockingObservable.java:340) ~[generated-intellij-deps.jar:?]
at com.microsoft.azure.management.storage.implementation.StorageAccountsInner.list(StorageAccountsInner.java:743) ~[generated-intellij-deps.jar:?]
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl.list(TopLevelModifiableResourcesImpl.java:118)
Expected behavior The response should be same everytime and should not give the above exception.
Setup
- Azure java sdk version : 1.24.2
- Azure key vault version : 1.2.2
Additional context We started seeing this exception when we recently upgraded out okhttp3 package. Similar issue can be seen here but is closed and should have been resolved with key vault version 1.2.2 : https://github.com/Azure/azure-sdk-for-java/issues/4879
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (9 by maintainers)
@vashisthsaurabh @ashbondu @manuelmazzuola @Tony-A-J-Martin @dy10 I’ve added some
response.close
in ResourceManagerThrottlingInterceptor, could you have a try with the 1.34.0?If the exception could be resolved I’ll close this issue. Thanks!
@ChenTanyi , I can confirm that for us, 1.34.0 resolves the
response.close()
issue. Now, instead of aRuntimeException
, we get aCloudException
and the retries are successfully carried out eventually resulting in a successful process. 🥳Thank you for you help @ChenTanyi , it is very much appreciated.