Android Question [SOLVED] How to disable ResponseError. Reason: java.net.ConnectException: Failed to connect to 112.141.12.120:1230, Response:

Binary Soft

Member
Licensed User
Longtime User
Hi,
in b4a I use below code to connect my server

B4X:
Sub TestConnection
    Try
        Dim j As HttpJob
        j.Initialize("", Me)
        j.Download("http://122.145.12.100:1230/test")
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Log(j.GetString)
        Else
            Log($"ErrorMessage = ${j.ErrorMessage}"$)
        End If
        j.Release
    Catch
        j.Release
    End Try
End Sub

App is work when internet is connected.
But there is no internet connection below error is shown in computer b4a's log even my app is released.

ResponseError. Reason: java.net.ConnectException: Failed to connect to 122.145.12.100:1230, Response:

So anyone can know my server's ip address and port in b4a's log just run my app in phone connect with computer.
How to disable log ResponseError. Reason: java.net.ConnectException: Failed to connect to 122.145.12.100:1230, Response:

This error texts are not from my log.
I noticed after run Wait For (j) JobDone(j As HttpJob).
It shows error if no internet connection.
If j.Success Then '<-- this line result is fail so my log also show: ErrorMessage = java.net.ConnectException: Failed to connect to /122.145.12.100:1230.

How can I disable showing errorMessage with ip address in computer's b4a's log when I run my release my app in my phone?
Thanks.

All logs are:

Logger connected to: 46c4fa70
--------- beginning of system
--------- beginning of main
** Activity (main) Pause event (activity is not paused). **
Sleep not resumed (context is paused): aa.test.b4xloadingindicator$ResumableSub_MainLoop

** Activity (main) Create **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
ResponseError. Reason: java.net.ConnectException: Failed to connect to /122.145.12.100:1230, Response:
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
ResponseError. Reason: java.net.ConnectException: Failed to connect to /122.145.12.100:1230, Response:
** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
ResponseError. Reason: java.net.ConnectException: Failed to connect to /122.145.12.100:1230, Response:
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
Do you still get the error is you remark this line:
B4X:
'Log($"ErrorMessage = ${j.ErrorMessage}"$) '<- comment/remark this line
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
set this compiler option: HU2_NOLOGS
the message comes from within okhttputils2 (httputils2service.bas):
B4X:
    #if Not(HU2_NOLOGS)
    Log($"ResponseError. Reason: ${Reason}, Response: ${Response.ErrorResponse}"$)
    #end if

if you set HU2_NOLOGS in the ide, that particular message is not logged
 
Upvote 1

Binary Soft

Member
Licensed User
Longtime User
Do you still get the error is you remark this line:
B4X:
'Log($"ErrorMessage = ${j.ErrorMessage}"$) '<- comment/remark this line
Yes, my log also shown.
ErrorMessage = java.net.ConnectException: Failed to connect to /122.145.12.100:1230
when I remark my code: 'Log($"ErrorMessage = ${j.ErrorMessage}"$) '<- comment/remark this line
It shows only ResponseError. Reason: java.net.ConnectException: Failed to connect to /163.47.8.23:51200, Response:
 
Upvote 0

Binary Soft

Member
Licensed User
Longtime User
set this compiler option: HU2_NOLOGS
the message comes from within okhttputils2 (httputils2service.bas):
B4X:
    #if Not(HU2_NOLOGS)
    Log($"ResponseError. Reason: ${Reason}, Response: ${Response.ErrorResponse}"$)
    #end if

if you set HU2_NOLOGS in the ide, that particular message is not logged
I use OkHttpUtils2 library. Where can I add HU2_NOLOGS?
I use below versions:
B4A ver12.80, OkUttpUtils2 v3.04, jdk-1.8, android-33.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
project ---> build configurations ---> conditional symbols
 
Upvote 0
Top