Hi all, i have 2 simple questions about B4J Server.
Question 1
I need to make a get request on a website (time by time), store the result value inside a global variable at (main) and i use this variable to show on handler pages.
the sub is like this.
Is this code correct? it is working perfect, but is the best solution or i need to use a timer (replace sleep for a timer)?
the server will stay online for a lot of days, every time the sub call the same sub again, this is good? or i will have problem with RAM,CPU usage etc??
my question is about performance of the webserver, what is the best here? timer or sleep?
Question 2
How works the DOS Filter on B4J Server?
This is enabled automatic when you start a server or need some configuration?
i have this line on my code, before the server start.
but this is sufficient?
i made a test, making a lot of requests to a page and i see the log
but i m not blocked, how works the block? how can i block the users making dos atack?
and if blocked how can i check the list of blocks and how unblock a user (ip)?
Obs: the page about DOS (@Erel ) are with the links off (not working)
if anyone has a working example of how to use the dos filter, show logs, block and unblock users and can share I appreciate it.
Thank you!
Question 1
I need to make a get request on a website (time by time), store the result value inside a global variable at (main) and i use this variable to show on handler pages.
the sub is like this.
B4X:
Private Sub Counter_Page
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://website.com/total")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim root As Map = parser.NextObject
Dim Total As Int = root.Get("Total")
totalPlacas = Total
Else
Log(j.ErrorMessage)
End If
j.Release
'CALL THE SUB AGAIN (EVERY 20 MINUTES)
Sleep(20 * 60000)
Counter_Page
End Sub
Is this code correct? it is working perfect, but is the best solution or i need to use a timer (replace sleep for a timer)?
the server will stay online for a lot of days, every time the sub call the same sub again, this is good? or i will have problem with RAM,CPU usage etc??
my question is about performance of the webserver, what is the best here? timer or sleep?
Question 2
How works the DOS Filter on B4J Server?
This is enabled automatic when you start a server or need some configuration?
i have this line on my code, before the server start.
B4X:
srvr.AddDoSFilter("/*", CreateMap("maxRequestMs": 5 * 60 * 1000)) '5 MINUTOS / FILTRO ATAQUE DOS
i made a test, making a lot of requests to a page and i see the log
2020-04-24 14:27:57.851:WARNejs.DoSFilter:qtp1288354730-11: DOS ALERT: Request delayed=100ms, ip=127.0.0.1, session=null, user=null
but i m not blocked, how works the block? how can i block the users making dos atack?
and if blocked how can i check the list of blocks and how unblock a user (ip)?
Obs: the page about DOS (@Erel ) are with the links off (not working)
DoSFilter Request Timeout
The DoSFilter helps with protection against denial of service attacks. It has various configuration options which are listed here: https://www.eclipse.org/jetty/documentation/current/dos-filter.html I was investigating a timeout issue with B4i OTA tool...
www.b4x.com
if anyone has a working example of how to use the dos filter, show logs, block and unblock users and can share I appreciate it.
Thank you!