Hi, I have this class:
Everything works perfectly. But if there are many parallel request, like:
I obtain this error:
How can I solve this, avoiding making requests one after the other? Thanks
HttpTask:
Sub Class_Globals
Dim ModuleCallback As Object
Dim SocketEvent As String
Dim HJRequest As HttpJob
End Sub
Public Sub Initialize (mCallback As Object, sEvent As String)
ModuleCallback = mCallback
SocketEvent = sEvent
HJRequest.Initialize("",Me)
End Sub
Public Sub ExecuteRemoteQuery (RemoteQuery As String, TaskId As Int)
Dim RemoteQueryStr As String = "cmd=" & RemoteQuery & "&version=" & Starter.VersionNumber
HJRequest.PostBytes(Starter.ServerAddress & "/" & Starter.RemoteQueryScript,RemoteQueryStr.GetBytes("UTF8"))
HJRequest.GetRequest.Timeout = Starter.TimeoutOffline
Wait For (HJRequest) JobDone (HJResponse As HttpJob)
Dim Success As Boolean = HJResponse.Success
If (Success = True) Then
Dim ResponseData As String = HJResponse.GetString2("UTF8")
CallSubDelayed3(ModuleCallback,SocketEvent & "_ResponseSuccess",ResponseData,TaskId)
Else
Dim Response As OkHttpResponse = HJResponse.Response
CallSubDelayed3(ModuleCallback,SocketEvent & "_ResponseError",Response,TaskId)
Response.Release
End If
HJResponse.Release
HJRequest.Release
End Sub
Everything works perfectly. But if there are many parallel request, like:
Activity sub:
Sub GetDataFromServer
If (Condition1) Then
Dim HT As HttpTask
HT.Initialize(Me,"CRSocket")
HT.ExecuteRemoteQuery("...params...",48)
End If
If (Condition2) Then
Dim HT As HttpTask
HT.Initialize(Me,"MBSocket")
HT.ExecuteRemoteQuery("...params...",50)
End If
If (Condition3) Then
Dim HT As HttpTask
HT.Initialize(Me,"TPSocket")
HT.ExecuteRemoteQuery("...params...",54)
End If
End Sub
I obtain this error:
B4X:
ResponseError - Reason: java.net.SocketTimeoutException
How can I solve this, avoiding making requests one after the other? Thanks
Last edited: