Android Question Translating an old app to B4XPages: Job returning empty string

GuyBooth

Active Member
Licensed User
Longtime User
One of my routines starts by counting records in a MariaDB database on a NAS.
In my Activity-based version, it has been working for many years, and still does.
In my B4XPages version, the HTTP Job returns an empty string.
I wrote a small test routine to eliminate some variable factors, and then added the code to both versions of the app and tested them. The code is:
B4X:
Sub Test_Job
    Dim cmd As String = "Select COUNT(*) FROM pieces WHERE PrimaryGroup like 'PG_%';"
    Dim Job As HttpJob
    Job.Initialize("", Me)
    Job.PostString(cmTMM.gsMySQLLink & sConnection, cmd)
    Wait For (Job) JobDone(Job As HttpJob)
    If Job.Success Then
        LogColor($"Success - Job.Getstring is: ${Job.Getstring}"$, Colors.Magenta)
    Else
        LogColor($"Not Successful"$, Colors.Red)
    End If
    Job.Release
End Sub
In both cases this code is run in a service.
In the Activity-based version this test code is called from an Activity Module called TMM_DBUpdates.
In the B4XPages version it is called from a B4X page class called B4XPTMM_DBUpdates.
In both cases, the calling code is simply:
B4X:
CallSub(TMM_DBService,"Test_Job")
The result in the log when the Activity version is run is:
B4X:
Success - Job.Getstring is: [{"COUNT(*)":"8595"}]
The result in the log when the B4XPages version is run is
B4X:
Success - Job.Getstring is:
So the B4XPages version only returns an empty string. The database and connections used are all identical. (unless I have missed something). A routine that deletes all the records in one of the database tables (that doesn't return a string) runs properly in both versions of the app, which would suggest that the connection string with passwords etc is properly set up.
What am I missing here?
 
Solution
1. No need to use CallSub in B4XPages. You can call it directly.
2. The problem is somewhere else. Add some log messages to verify the variables values.
Is there a performance advantage to calling subs directly?

Good advice as always. Turns out the (Hidden) password was incorrect in the B4XPages version.
It is now working.

GuyBooth

Active Member
Licensed User
Longtime User
1. No need to use CallSub in B4XPages. You can call it directly.
2. The problem is somewhere else. Add some log messages to verify the variables values.
Is there a performance advantage to calling subs directly?

Good advice as always. Turns out the (Hidden) password was incorrect in the B4XPages version.
It is now working.
 
Upvote 0
Solution

kamran5734

New Member
1 change httputils2 lib to okhttputils2
2 put this in manifest
SetApplicationAttribute(android:usesCleartextTraffic, "true")
 
Upvote 0
Top