Android Question [Solved] JRDC2 and SQL Server: B4A client issue or SQL server or firewall?

Batman_

Member
Licensed User
I am going through the tutorial from this post:
From the tutorial I have managed to start the webserver and can confirm the connection to the SQL server database is working. I get the confirmation message as per below when I run the test URL (http://169.254.13.143:17178/test) to test the connection.
RemoteServer is running (09/17/2021 15:45:49)
Connection successful.

Initial error message
I have created the B4A client app as per the tutorial. Initially I got the following error message:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy

To resolve this I updated the Manifest with the following code:
Error log:
SetApplicationAttribute(android:usesCleartextTraffic, "true")
.

When I re-run the B4A client app I now get the following message in the log:
Error log from B4A:
Logger connected to:  TCL T810H
--------- beginning of main
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38098) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out), Response:
ERROR: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38098) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38106) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out), Response:
ERROR: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38106) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38110) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out), Response:
ERROR: java.net.SocketTimeoutException: failed to connect to /169.254.13.143 (port 17178) from /192.168.1.100 (port 38110) after 30000ms: isConnected failed: ETIMEDOUT (Connection timed out)

For reference, please note that in the Manifest editor that the android:targetSdkVersion="29" and I have disabled Windows Firewall (for testing purposes). The 192.168.1.100 refers to the B4A bridge IP. The IP 169.254.13.143 refers to SQL Server and should be working as per the "Connection Successful" message after starting the Webserver.

Any help in diagnosing the error message is much appreciated as I know it may be a SQL Server issue rather than the B4A client or even firewall (although I have temporarily disabled the Windows Firewall).

Although the Webserver appears to be working properly (for your reference) below is the connection string to the SQL Server database:
config.properties in B4J webserver app:
DriverClass=net.sourceforge.jtds.jdbc.Driver
JdbcUrl=jdbc:jtds:sqlserver://169.254.13.143/TestSQLServer

User=Test
Password=Test

#Java server port
ServerPort=17178

Partial list of SQL Server settings
The attached image show some of the settings for my SQL Server (which may be the issue):
SQL Server settings.JPG


I have also attached the B4A client program.

Any help in diagnosing the error message is much appreciated as I know it may be a SQL Server issue rather than the B4A client or even firewall (although I have temporarily disabled the Windows Firewall).

Thanks in advance.
 

Attachments

  • TestWebApp1.zip
    221.4 KB · Views: 19
Solution
Initial error message
I have created the B4A client app as per the tutorial. Initially I got the following error message:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy

To resolve this I updated the Manifest with the following code:
B4X:
SetApplicationAttribute(android:usesCleartextTraffic, "true")
.

The recommended solution is:

DonManfred

Expert
Licensed User
You are connecting to the sql-server from within B4A? You need to connect to the server running jRDC2. jrdc2 connects to the sql-server...
There is no jrdc2 running on the SQL-Server IP...

You need to connect to http://169.254.13.143:17178 your public ip of the jRDC2-Server i guess...
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Forget about my comments above in post #5.

I suggest the PC that is running the jRDC server must make sure it connected to the same WiFi as the Android phone which the IP is 192.168.1.XXX
For example: 192.168.1.99
Then test from browser whether can open http://192.168.1.99:17178/test
 
Upvote 0

aeric

Expert
Licensed User
Initial error message
I have created the B4A client app as per the tutorial. Initially I got the following error message:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 169.254.13.143 not permitted by network security policy

To resolve this I updated the Manifest with the following code:
B4X:
SetApplicationAttribute(android:usesCleartextTraffic, "true")
.

The recommended solution is:
 
Upvote 1
Solution

José J. Aguilar

Expert
Licensed User
I agree with aeric. From wikipedia

If a host on an IEEE 802 (Ethernet) network cannot obtain a network address via DHCP, an address from 169.254.1.0 to 169.254.254.255[Note 2] may be assigned pseudorandomly. The standard prescribes that address collisions must be handled gracefully.

So, the server and the client are not in the same network. (or even the server is not connected to the network). The test works but I guess just from the computer itself where the jRDC2 server is running, but no from any other.

@Batman_ you must test http://169.254.13.143:17178 from another computer. If your android ip is something like 192.168.x.x then your server must have an address like that (192.168.x.x)...
 
Upvote 0

Spavlyuk

Member
Licensed User
Try opening the test url from the browser of your android device. If the page does not load it's a network/firewall issue.
 
Upvote 0

Batman_

Member
Licensed User
First, thanks to everyone who has provided assistance.

It was indeed a network setting issue. I am attaching the process I used to find the correct IP Address and SQL Server settings to use should someone come to this post in the future.

I also updated the Manifest as per aeric, post #8.

The administrator can now close off this thread.

Thanks.
 

Attachments

  • IP Settings.pdf
    511.9 KB · Views: 18
Upvote 0
Top