B4J Question HTTP JOB PROBLEM

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hi Everyone,

Could anybody help me , I'm facing whit the following situation, i try to get data from a web service , in "production app" it doesn't work , i moved the code in a test app and there it's working perfect. If i check with debugger the prompter stop here "Wait For(j) jobdone(j As HttpJob)"it seems that the job is not released,no error message. What should i try or change?
As you can see in the attached image all library are the same. thank you.
 

Attachments

  • strange_behavior.png
    strange_behavior.png
    107.5 KB · Views: 119

MarcoRome

Expert
Licensed User
Longtime User
Here work the response is:
JSON:
{"cod":200,"message":"SUCCESS","found":[{"cui":39462862,"data":"2022-10-22","denumire":"SMART CAS TECH S.R.L.","adresa":"JUD. BIHOR, MUN. ORADEA, SPL. CRIŞANEI, NR.9/A, BL.A3, AP.12","nrRegCom":"J05/1379/2018","telefon":"0744706796","stare_inregistrare":"INREGISTRAT din data 08.06.2018","scpTVA":true,"data_inceput_ScpTVA":"2018-07-25","data_sfarsit_ScpTVA":" ","data_anul_imp_ScpTVA":" ","mesaj_ScpTVA":"platitor IN SCOPURI de TVA la data cautata","dataInceputTvaInc":"","dataSfarsitTvaInc":"","dataActualizareTvaInc":"","dataPublicareTvaInc":"","tipActTvaInc":"","statusTvaIncasare":false,"dataInactivare":" ","dataReactivare":" ","dataPublicare":" ","dataRadiere":" ","statusInactivi":false,"dataInceputSplitTVA":"","dataAnulareSplitTVA":"","statusSplitTVA":false,"iban":"","statusRO_e_Factura":false,"sdenumire_Strada":"Spl. Crişanei","snumar_Strada":"9/A","sdenumire_Localitate":"Mun. Oradea","scod_Localitate":"316","sdenumire_Judet":"BIHOR","scod_Judet":"5","stara":" ","sdetalii_Adresa":" ","scod_Postal":" ","ddenumire_Strada":"Spl. Crişanei","dnumar_Strada":"9/A","ddenumire_Localitate":"Mun. Oradea","dcod_Localitate":"316","ddenumire_Judet":"BIHOR","dcod_Judet":"5","dtara":" ","ddetalii_Adresa":" ","dcod_Postal":" ","data_inregistrare":"2018-06-08","cod_CAEN":"4651"}],"notfound":[]}

What mean in "production app" ?? who compiles or what ?
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
Try this it should work. It helps retry until the requests goes through.
B4X:
    Dim j As HttpJob
    j.Initialize("",Me)
    For retries = 1 To 10
        j.PostString("https://xxx.xxxx.xxx.xxx/xx/xxx/","")
        wait for (j) JobDone(job As HttpJob)
        Success = job.Success
        If Success Then
            Exit
        Else If Not(Success) Then
            Sleep(500)
        End If
        j.Release
    Next
 
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
Here work the response is:
JSON:
{"cod":200,"message":"SUCCESS","found":[{"cui":39462862,"data":"2022-10-22","denumire":"SMART CAS TECH S.R.L.","adresa":"JUD. BIHOR, MUN. ORADEA, SPL. CRIŞANEI, NR.9/A, BL.A3, AP.12","nrRegCom":"J05/1379/2018","telefon":"0744706796","stare_inregistrare":"INREGISTRAT din data 08.06.2018","scpTVA":true,"data_inceput_ScpTVA":"2018-07-25","data_sfarsit_ScpTVA":" ","data_anul_imp_ScpTVA":" ","mesaj_ScpTVA":"platitor IN SCOPURI de TVA la data cautata","dataInceputTvaInc":"","dataSfarsitTvaInc":"","dataActualizareTvaInc":"","dataPublicareTvaInc":"","tipActTvaInc":"","statusTvaIncasare":false,"dataInactivare":" ","dataReactivare":" ","dataPublicare":" ","dataRadiere":" ","statusInactivi":false,"dataInceputSplitTVA":"","dataAnulareSplitTVA":"","statusSplitTVA":false,"iban":"","statusRO_e_Factura":false,"sdenumire_Strada":"Spl. Crişanei","snumar_Strada":"9/A","sdenumire_Localitate":"Mun. Oradea","scod_Localitate":"316","sdenumire_Judet":"BIHOR","scod_Judet":"5","stara":" ","sdetalii_Adresa":" ","scod_Postal":" ","ddenumire_Strada":"Spl. Crişanei","dnumar_Strada":"9/A","ddenumire_Localitate":"Mun. Oradea","dcod_Localitate":"316","ddenumire_Judet":"BIHOR","dcod_Judet":"5","dtara":" ","ddetalii_Adresa":" ","dcod_Postal":" ","data_inregistrare":"2018-06-08","cod_CAEN":"4651"}],"notfound":[]}

What mean in "production app" ?? who compiles or what ?
Hi Marco , production app is our internal CRM. Because the web service part doesn't work in our CRM , i made a test app (top of the attached image) in which it works, the same code in CRM does not work.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
I watched the video. The links look exactly the same to me. So I still can't understand when you talk about "production App" what you mean.
The code in B4J is correct.
 
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
I watched the video. The links look exactly the same to me. So I still can't understand when you talk about "production App" what you mean.
The code in B4J is correct.
Hi, I know that the code is correct , question is why in test app is working and the same code in other app does not working
 
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
Did you try my approach ?
Hi , yes i tried, below the error message
javax.net.ssl.SSLPeerUnverifiedException: Hostname xxx.xxxx.xxx.xxx not verified:
certificate: sha256/WXuNYlG8IVQ9lYktKJMJYSIoX7HhRL5aCt3iYim0skY=
DN: CN=xxx.xxx
subjectAltNames: [xxx.xxx, *.xxx.xxx]
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:334)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:284)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:169)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:258)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257)
at okhttp3.RealCall.execute(RealCall.java:93)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:175)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:172)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:220)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
ResponseError. Reason: javax.net.ssl.SSLPeerUnverifiedException: Hostname xxx.xxxx.xxx.xxx not verified:
certificate: sha256/WXuNYlG8IVQ9lYktKJMJYSIoX7HhRL5aCt3iYim0skY=
DN: CN=xxx.xxx
subjectAltNames: [xxx.xxx, *.xxx.xxx], Response:
javax.net.ssl.SSLPeerUnverifiedException: Hostname xxx.xxxx.xxx.xxx not verified:
certificate: sha256/WXuNYlG8IVQ9lYktKJMJYSIoX7HhRL5aCt3iYim0skY=
DN: CN=xxx.xxx
subjectAltNames: [xxx.xxx, *.xxx.xxx]
 
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hi Erel, I did the changes based on you advice , same behavior. If you see the video in post #5 httpjob does not work in our CRM , same code copied in a test app work perfect (both app are compiled on a same machine)
The CRM works perfect since 3 years until i updated b4j to 9.80.
 

Attachments

  • Untitled.png
    Untitled.png
    3.7 KB · Views: 58
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Some time ago I had problems with SSL certificates, with some client websites.
You can try this:

#PackagerProperty: VMArgs = --add-opens java.base/sun.security.ssl=b4j
#PackagerProperty: IncludedModules = jdk.crypto.ec
can indicate the version of the protocol
SetSystemProperty("jdk.tls.client.protocols","TLSv1,TLSv1.1,TLSv1.2")
SetSystemProperty("deployment.security.TLSv1.2","true")
SetSystemProperty("https.protocols","TLSv1.2")

B4X:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 620
    #PackagerProperty: VMArgs = --add-opens java.base/sun.security.ssl=b4j
    #PackagerProperty: IncludedModules = jdk.crypto.ec
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    SetSystemProperty("jdk.tls.client.protocols","TLSv1,TLSv1.1,TLSv1.2")
    SetSystemProperty("deployment.security.TLSv1.2","true")
    SetSystemProperty("https.protocols","TLSv1.2")

1666863263187.png
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Hi , yes i tried, below the error message
The problem is, you tried his approach w/o changing the
portion to your URL. You just left it as is? At least that's what the error message in your post shows.

You can try this:
HU2_ACCEPTALL should be a last resort. You may as well not use HTTPS at that point. If that does work, then I would recommend updating the certificate on the server.

"jdk.tls.client.protocols","TLSv1,TLSv1.1,TLSv1.2"
If enabling later TLS protocols work, great, but again you should (if the server is under your control), if possible, disable older protocols on the server. This may be tougher, since older client programs may rely on the fact that older protocols work. But again, there is a reason older protocols are disabled and it's getting to the point that using these older protocols gives you more "security through obscurity" safety than actual "security through proper encryption" safety.
 
Upvote 0
Top