Two months back I did my first project on B4A 1.3, using HTTP library 1.0. The app was working perfectly and soon I moved on to the second project. I finished the second app 2 weeks back in B4A 1.5 with HTTP library 1.10. Still everything fine.
Now today I had to go back to my 1st project to release an update. The update is unrelated to http; it is to add a new msgbox, that is all. But now in the new update the HTTP part stays hung up for a long time and eventually returns an error.
In the app, there is a list of 20-30 images to be downloaded at a time. At that time Erel hasn't released HttpUtils, so to avoid concurrent execution rejection error, I had to use a Do While Loop with DoEvents. I know that is not the best practice to attain this but still it was relatively simple and worked correctly. Here is the partial code:
Sub HandleMainPage (in As InputStream)
.
.
.
connections=0
For i=1 To icount
request.InitializeGet(url)
request.Timeout = 10000 'set timeout to 10 seconds
Do While connections>10
DoEvents
Loop
connections=connections+1
If HttpClient1.Execute(request, i) = False Then Return
Next
.
.
.
End Sub
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
connections=connections-1
.
.
.
End Sub
Sub HttpClient1_ResponseError(Reason As String, StatusCode As Int, TaskId As Int)
connections=connections-1
.
.
.
End Sub
This used to work correctly on B4A 1.3 + HTTP library 1.0. Now on B4A 1.5 + HTTP library 1.10, this code creates an infinite loop at the Do While connections>10 part. When I check the log, I can see that HttpClient1_ResponseError or HttpClient1_ResponseSuccess doesn't get executed. Also in the logs, every 2 minutes or so of running the infinite loop, it posts an error message "failed: A network error occurred."
I have the old version on my tablet and it works fine. The new version on phone which was compiled today with the latest B4A and HTTP lib is getting stuck in the loop. Please look into this immediately.