hello
I need some advice ...
I have read html pages every two minutes to extract the information.
Here I prepare the task ..
B4X:
Dim task As Int=0
Dim job(tabella.Size ) As HttpJob
For Each riga As st_tabella In tabella
job(task).Initialize (task,Me)
job(task).Download("http://www.miosito.com/" & riga.Nome)
job(task).GetRequest.timeout=4000
Log("inizialize job=" & task & " Nome :" & riga.Nome)
task=task+1
Next
numJob = task
Here are executed.
B4X:
Sub JobDone(job As HttpJob)
Dim st As JStringFunctions
If job.Success = True Then
Log("JobName = " & job.JobName & " JobSuccess = " & job.Success )
.
.
.
.
Else
Log("Error: " & job.ErrorMessage)
End If
numJob=numJob-1
If numJob =0 Then
Log("********* end all job **********")
.
.
.
.
End If
End Sub
Unfortunately, I often get timeout errors, which do not allow me to see if the task was completed (numJob <>0).
Is there a way to determine the end of the task? (some event)
The program includes a reading of about 60 html pages.
With a timer run every 2 minutes reading this.
After the reading I should submit a summary .. If I do not know if I've finished the job ... I can not provide the data.
I have done debugging.
Sometimes I get runtime error, and it seems that the job is not executed, because the variable "numjob" is not decreased, so the condition does not occur "numjob = 0" indicates to me that the end of the readings.
In JobDone occasionally I get this error in the log:
org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.200:80 timed out
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:125)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:133)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at anywheresoftware.b4a.http.HttpClientWrapper.executeWithTimeout(HttpClientWrapper.java:310)
at anywheresoftware.b4a.http.HttpClientWrapper.access$0(HttpClientWrapper.java:308)
at anywheresoftware.b4a.http.HttpClientWrapper$ExecuteHelper.run(HttpClientWrapper.java:207)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Error: org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.200:80 timed out