Android Question B4A app unable to connect to local MariaDB

toby

Active Member
Licensed User
Longtime User
I have published some apps with MariaDB as backend database and now I need to setup WAMP on my local laptop for future development of those apps. I only want the WAMPServer works locally, so I assume that firewall shouldn't be an issue.

I've basically followed this tutorial step by step; the only difference is that the tutorial calls for XAMP while I use WAMPServer 3.2.26 which has been installed recently.

The only thing that doesn't work is that B4A app trying to connect to the DB resulted in timeout when adding a new person. I didn't change the persons.php file. I'm wondering how others solve the problem. Thank a lot in advance.

B4X:
Sub InsertNewPersonButton_Click
 
    If NameET.Text.Length<2 Then
       Log("Name is missing or to short")
       Return
    End If
 
    If AgeET.Text = "" Then
       Log("Age is missing")
       Return
    End If
         
    Dim InsertNewPerson As HttpJob
    InsertNewPerson.Initialize("InsertNewP", Me)
 
    InsertNewPerson.download2("http://" & ServerIP & "/persons/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text))
    'InsertNewPerson.GetRequest.Timeout=40000
 
    Wait For (InsertNewPerson) JobDone(j As HttpJob)

    If j.Success=False Then
        Log(j.ErrorMessage)
        ToastMessageShow("No internet connection", True)
        j.Release 'no internet
        Return
    End If
    Log(": j.GetString=" & j.GetString)
End sub
This is filtered logs:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 90 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'org.apache.http.params.HttpParams org.apache.http.client.methods.HttpRequestBase.getParams()' on a null object reference
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.setTimeout(HttpClientWrapper.java:442)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:8160)
at android.widget.TextView.performClick(TextView.java:16222)
at android.view.View.performClickInternal(View.java:8137)
at android.view.View.access$3700(View.java:888)
at android.view.View$PerformClick.run(View.java:30236)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8550)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.11:80 timed out
Unfiltered logs:
org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.11:80 timed out
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:126)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:199)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:174)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:139)
at org.apache.http.impl.client.DefaultRequestDirector.executeOriginal(DefaultRequestDirector.java:1314)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:698)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:470)
at anywheresoftware.b4a.http.HttpClientWrapper.executeWithTimeout(HttpClientWrapper.java:316)
at anywheresoftware.b4a.http.HttpClientWrapper.access$0(HttpClientWrapper.java:314)
at anywheresoftware.b4a.http.HttpClientWrapper$ExecuteHelper.run(HttpClientWrapper.java:215)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
assignNativeObject: nativeObject = 0 Surface(name=null)/@0xe071b6b / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
Relayout returned: old=(0,1123,719,1339) new=(0,1168,719,1339) req=(719,171)0 dur=33 res=0x100023 s={true 4061357056} ch=true fn=-1
nativeRelease nativeObject s[3812587552]
nativeRelease nativeObject e[3812587552]
nativeRelease nativeObject s[3812587072]
nativeRelease nativeObject e[3812587072]
nativeRelease nativeObject s[4055011840]
nativeRelease nativeObject e[4055011840]
MSG_WINDOW_FOCUS_CHANGED 0 1
MSG_WINDOW_FOCUS_CHANGED 1 1
org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.11:80 timed out
nativeRelease nativeObject s[4022022528]
nativeRelease nativeObject e[4022022528]
assignNativeObject: nativeObject = 0 Surface(name=null)/@0xe071b6b / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
nativeRelease nativeObject s[3812587808]
modified test app attached
 

Attachments

  • b4a_app_xampp2.zip
    9 KB · Views: 18
Solution
WAMPServer 3.2.6 comes with Mysql and MariaDB, both of them are installed and were selected on my computer. It finally works after I deselected Mysql as shown in the attached image

access denied.jpg

MicroDrie

Active Member
Licensed User
The old procedure said
Open your browser and type: 127.0.0.1. Chose you language and click on "Status". Here you can see which "services" are working:
By using the address 127.0.0.1, the nowadays internal strict Windows Firewall is bypassed. If your program code do not use this 127.0.0.1 address in the variable ServerIP traffic is blocked and a time error is the result. Check your firewall if all used ports are opened fro the ip-addresses for your app.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Before testing to INSERT data to the DB, try SELECT some data from the DB and see whether it can be show from the browser.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I only want the WAMPServer works locally, so I assume that firewall shouldn't be an issue.
It IS an issue if the php can not be reached. The php must be accessible from outside otherwise it will not work.
You firewall have to be open on some ports (all needed).
 
Last edited:
Upvote 0

PaulMeuris

Member
Licensed User
You could use as ServerIP your local IP address and the correct port. Check the Apache settings of Wampserver, Xampp or Uwamp.
Uwamp: 192.168.1.190:443 (replace IP with your info)
Xampp: 192.168.1.190:80
Your local IP address of course can be find using the command prompt from Windows: ipconfig /all
 
Upvote 0

toby

Active Member
Licensed User
Longtime User
WAMPServer 3.2.6 comes with Mysql and MariaDB, both of them are installed and were selected on my computer. It finally works after I deselected Mysql as shown in the attached image

access denied.jpg
 
Last edited:
Upvote 0
Solution

aeric

Expert
Licensed User
Longtime User
That’s why I prefer Laragon and this issue won’t happen as only one MySQL engine can be selected at one time.
 
Upvote 0
Top