1

I am trying to list subscriptions using mgmt-resource SDK -ver 1.2.1. I am having some issues which I pasted below. I am behind a proxy and created a ResourceManager.Authenticated object using proxy. Then using that object I was able to execure auth.subscriptions without an issue. I see on console auth is successful and code returns some guids indicating successful authentication.. But when I execute subs.list I got exception. I tried with listAsync, too. But same issue. (I could not paste all code it here because of formatting). Exception is "Too many tunnel connections attempted: 21" I could not find any solutions. Any ideas what am I missing or what is wrong? I'd appreciate any work around. Thanks...

Subscriptions subs = auth.subscriptions();
List<Subscription> subsList =subs.list();

And exception message:

[pool-1-thread-1] INFO com.microsoft.aad.adal4j.AuthenticationAuthority - [Correlation ID: 099b5a45-5f2c-470a-914e-cd19c16ee0bc] Instance discovery was successful
java.lang.RuntimeException: java.net.ProtocolException: Too many tunnel connections attempted: 21
    at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
    at rx.observables.BlockingObservable.single(BlockingObservable.java:341)
    at com.microsoft.azure.management.resources.implementation.SubscriptionsInner.list(SubscriptionsInner.java:244)
    at com.microsoft.azure.management.resources.implementation.SubscriptionsImpl.list(SubscriptionsImpl.java:38)
    at AzureLogin.test2(AzureLogin.java:76)
    at AzureLogin.main(AzureLogin.java:24)
Caused by: java.net.ProtocolException: Too many tunnel connections attempted: 21
    at okhttp3.internal.io.RealConnection.buildTunneledConnection(RealConnection.java:148)
    at okhttp3.internal.io.RealConnection.connect(RealConnection.java:108)
    at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:187)
    at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123)
    at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:93)
    at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:296)
    at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
    at okhttp3.RealCall.getResponse(RealCall.java:243)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
    at com.microsoft.rest.retry.RetryHandler.intercept(RetryHandler.java:75)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.rest.interceptors.CustomHeadersInterceptor.intercept(CustomHeadersInterceptor.java:140)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.rest.interceptors.UserAgentInterceptor.intercept(UserAgentInterceptor.java:83)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.azure.credentials.AzureTokenCredentialsInterceptor.intercept(AzureTokenCredentialsInterceptor.java:40)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor.intercept(ResourceManagerThrottlingInterceptor.java:43)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor.intercept(ProviderRegistrationInterceptor.java:43)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.rest.interceptors.BaseUrlHandler.intercept(BaseUrlHandler.java:43)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at com.microsoft.rest.interceptors.RequestIdHeaderInterceptor.intercept(RequestIdHeaderInterceptor.java:29)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
    at okhttp3.RealCall.execute(RealCall.java:57)
    at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
    at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171)
    at rx.Subscriber.setProducer(Subscriber.java:211)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
    at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)
    at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)
    at rx.Observable.unsafeSubscribe(Observable.java:10142)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.Observable.subscribe(Observable.java:10238)
    at rx.Observable.subscribe(Observable.java:10205)
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:444)
    ... 5 more
user3499779
  • 23
  • 1
  • 6
  • Your codes work for me. According to the error log, `Too many tunnel connections attempted` wait for a moment and get the same error log? – Shui shengbao Sep 15 '17 at 02:42
  • I placed a 1 min sleep just before the line that I got exception, but still happening. It did not solve. Thanks – user3499779 Sep 25 '17 at 13:23
  • If possible, I suggest you could create a new service principal and test code again. Please refer to this [link](https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal). – Shui shengbao Sep 26 '17 at 05:56
  • I checked without proxy using same account credentials. Code is working. Something about proxy and company network... – user3499779 Sep 26 '17 at 15:51
  • It is interesting, I tried again in company network, I waited longer this time in debug mode. Somehow I did not get an exception. Then I place 2 mins, 1 min, 1 sec and finally deleted sleep. And again it worked in all cases. Then after 3 or 4 hrs later ran it again and failed even I placed sleep. – user3499779 Sep 26 '17 at 21:01
  • It seems a proxy issue. Your code works for me, I am sure. You could try the code without proxy. – Shui shengbao Sep 27 '17 at 05:49
  • You could check this quesiton https://stackoverflow.com/questions/46153940/not-able-to-login-to-azure-from-eclipse – Shui shengbao Sep 27 '17 at 05:50
  • Code works without proxy as I had mentioned before. I know I set proxy properly because we use storage SDK for other purposes like SAS Tokens and etc. Also I made the code work only once behind proxy. Thanks. – user3499779 Sep 28 '17 at 21:23

0 Answers0