Android Question Some solution with jRDC2 connections

bollanog

Member
Hello good night, I have used the following code in my b4a application.

B4X:
Sub Process_Globals

   Type DBResult (Tag As Object, Columns As Map, Rows As List)

   Type DBCommand (Name As String, Parameters() As Object)

   Private const rdcLink As String = "http://192.168.0.6:17178/rdc"

End Sub



Sub CreateRequest As DBRequestManager

   Dim req As DBRequestManager

   req.Initialize(Me, rdcLink)

   Return req

End Sub



Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand

   Dim cmd As DBCommand

   cmd.Initialize

   cmd.Name = Name

   If Parameters <> Null Then cmd.Parameters = Parameters

   Return cmd

End Sub



Sub GetRecord (id As Int)

   Dim req As DBRequestManager = CreateRequest

   Dim cmd As DBCommand = CreateCommand("select_animal", Array(id))

   Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)

   If j.Success Then

       req.HandleJobAsync(j, "req")

       Wait For (req) req_Result(res As DBResult)

       'work with result

       req.PrintTable(res)

   Else

       Log("ERROR: " & j.ErrorMessage)

   End If

   j.Release

End Sub

From the following address, https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/ and everything has been excellent with the connection to the b4j server, but the server hangs when there are several requests.

Is there a way instead of using b4j or creating a server for visual studio c #?
 

aeric

Expert
Licensed User
Longtime User
everything has been excellent with the connection to the b4j server, but the server hangs when there are several requests.
You mean you run it in release mode with a lot of requests? How many request in 1 time?

Is there a way instead of using b4j or creating a server for visual studio c #?
If you don't want to use B4J, you can build your own with your favourite language such as Python, Javascript, Ruby, Perl, etc.
OR if you could develop web services with PHP, C#, JSP then just use existing web servers that support these languages such as Apache, nginx, IIS or Tomcat to name a few.

There are also other B4J projects such as ABMaterial, BANano, BANanoVueMaterial and BANanoVueAD.
With JRDC2 solution, one can develop both the server and clients with one familiar language i.e. B4X (B4J, B4A, B4i IDEs share the same syntax).
I made my own B4J server with slightly different approach which output or return response as json or html. So, I can use the same API for B4A, B4i, B4J and any web application developed in PHP, Javascript, jQuery, C#, VB, etc.

You are not mandatory to use JRDC2 to build a server to connect the remote database with B4A, B4i or even B4J clients. You can use the technologies I mentioned in first paragraph and make web services or API to use in clients developed in these 3 platforms (or other technology).

I also use Laragon with PHP as my local development web server.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Huh? What hangs? Any logs? Please note that without logs you may be pointing your finger at the wrong culprit. I’ve tested jRDC2 under full network load (saturating 1Gbit network) and even locally without any “hang up” issues. There are many moving parts. Are you sure it’s not you DB backend? The network infrastructure? Just an issue with configuring pooling for your use case? And what do you consider several requests? 10? 100? 1000? More?
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hello @bollanog

I don't understand what you're talking about, what error does the B4J Log get when the jRDC2 is running?

I have a mobile app in B4A for orders and invoices that works with 50 users and never hangs with any request
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
I didn't encounter a hang in B4J server too.

Users are more than 100, don't know how many concurrent connections at one time.
 
Last edited:
Upvote 0

bollanog

Member
Hello, good afternoon, sorry for not responding quickly, I have had connection problems. As for B4j, there is a moment that it freezes and the android application waits for the answer, when I try to close the server it responds to the requests.

It is something strange, the server has 4gb of ram and Intel Xeon 2.10Ghz 4-core processor. On the requests was put and a calculation of 40 ~ 50 requests per minute was made.

It seems that it was rather the java that is screwing us.

But the system is very good communications, has another thing we use the database SQLSERVER 2008 R2.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
How are you running the jRDC2 server? To which DB is it talking? Where is the DB located (local or remote)? What is the error that is produced by jRDC2 when it "hangs"? We really need to see the logs before anything can be said about the issue you are perceiving.

As a counterpoint to your powerful machine, my testing machine is just a Celeron 1037U, 4GB RAM and 64GB SATA SSD ().

Looking at my old testing data, using jRDC2 running on the above mention box w/MySQL running on the same box, 20 clients over a duration of 60 seconds were able to insert over 12000 test records. The insert statement was configured as
B4X:
sql.insert_students2=INSERT INTO Students2 (Id, `First Name`, `Last Name`, Birthday, Image) VALUES (?, ?, ?, ?, ?)
where the image was an average of 30KB per record.
Without the image, over 60000 records were inserted.
 
Upvote 0

bollanog

Member
How are you running the jRDC2 server?
Used to run with a bat file.

B4X:
Used to run with a bat file.
@echo off
java -jar run.jar
@pause

To which DB is it talking?
SQLSERVER 2008 R2

Where is the DB located (local or remote)?
Local

What is the error that is produced by jRDC2 when it "hangs"?
It does not generate any error log, it just waits for a request but when it does a Control C to close it receives the connection from the client and sends the response to the client.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is a "special" feature of Windows command line, that I've once wasted many hours because of it. This feature alone is enough to switch to Linux for your server.

If you click on the command line window it pauses the process without showing any indication.

This might be the cause of the issue. Properly built B4J servers, such as jRDC2, never hang.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…