Ive often errors in my Server Handler, but dont know how to fix it:
ResponseError. Reason: Too Many Requests, Response:
This is my code
ResponseError. Reason: Too Many Requests, Response:
This is my code
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim v As String =req.GetParameter("Version")
newClient(req.GetParameter("IP"),resp,v)
StartMessageLoop
End Sub
Sub newClient(adress As String,resp As ServletResponse,version As String)
Dim job As HttpJob
job.Initialize("loc",Me)
job.Download("http://ip-api.com/json/" & adress.Trim)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Dim parser As JSONParser
parser.Initialize(job.GetString)
Dim root As Map = parser.NextObject
Dim status As String = root.Get("status")
If status = "success" Then
analyticClass.activeClients.Put(adress,CreateMap("timestamp":DateTime.Now,"version":version))
End If
Else
logger.write("could not fetch address for " & adress)
End If
resp.Write("")
job.Release
StopMessageLoop
End Sub