softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.46k stars 309 forks source link

java.lang.UnsupportedOperationException: Couldn't connect to the proxy server. #1031

Closed jurijkruske closed 3 years ago

jurijkruske commented 3 years ago

we are using last version of sttp with okHttpBackend 3.3.9 to call external service with proxy. Sometimes we are receiving strange error from SttpBackendOptions, but we cannot see the real error from network layer.

java.io.IOException: canceled due to java.lang.UnsupportedOperationException: Couldn't connect to the proxy server. at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:530) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Suppressed: java.lang.UnsupportedOperationException: Couldn't connect to the proxy server. at sttp.client3.SttpBackendOptions$Proxy$$anon$1.connectFailed(SttpBackendOptions.scala:86) at okhttp3.internal.connection.RealConnection.connectFailed$okhttp(RealConnection.kt:691) at okhttp3.internal.connection.RealConnection.trackFailure$okhttp(RealConnection.kt:730) at okhttp3.internal.connection.Exchange.trackFailure(Exchange.kt:167) at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:111) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517) ... 3 common frames omitted

Checking the code of SttpBackendOptions on live 86

    override def connectFailed(uri: net.URI, sa: SocketAddress, ioe: IOException): Unit = {
      throw new UnsupportedOperationException("Couldn't connect to the proxy server.")
    }

Would be it possible to add the message from IOException to UnsupportedOperationException? It will help to find the network issue. Thanks Jurij

adamw commented 3 years ago

Of course - should be a simple PR - maybe you could try preparing it?