B4J Question HttpJob proxy settings

JaviP

Member
Licensed User
I try to use the proxy settings for HttpJob.

This is my code:
B4X:
SetSystemProperty("http.proxyHost", ProxyHost)
SetSystemProperty("http.proxyPort", ProxyPort)
SetSystemProperty("http.proxyUser", ProxyUsername)
SetSystemProperty("http.proxyPassword", ProxyPassword)
SetSystemProperty("https.proxyHost", ProxyHost)
SetSystemProperty("https.proxyPort", ProxyPort)
SetSystemProperty("https.proxyUser", ProxyUsername)
SetSystemProperty("https.proxyPassword", ProxyPassword)
...
Job.PostString("https://miurl/send", "prueba")
Job.GetRequest.SetContentType("application/json, application/x-www-form-urlencoded")
Job.GetRequest.SetHeader("Authorization", "key=" & Constantes.API_KEY)

Dim credenciales As JavaObject
credenciales.InitializeStatic("okhttp3.Credentials")
Dim credencialesStr As String
credencialesStr = credenciales.RunMethod("basic", Array (ProxyUsername, ProxyPassword))
    
Job.GetRequest.SetHeader("Proxy-Authorization", credencialesStr)
Job.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0")
Job.GetRequest.SetHeader("Proxy-Connection", "keep-alive")

Job.Username = ProxyUsername
Job.Password = ProxyPassword
Result:
B4X:
java.io.IOException: Failed to authenticate with proxy
    at okhttp2.internal.connection.RealConnection.createTunnel(RealConnection.java:321)
    at okhttp2.internal.connection.RealConnection.buildTunneledConnection(RealConnection.java:155)
    at okhttp2.internal.connection.RealConnection.connect(RealConnection.java:111)
    at okhttp2.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:196)
    at okhttp2.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:132)
    at okhttp2.internal.connection.StreamAllocation.newStream(StreamAllocation.java:101)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
    at okhttp3.RealCall.execute(RealCall.java:63)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:156)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:153)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:201)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
At this time, Is not posible establish user and password for the proxy?
 
Last edited:
Top