Friends ,
I am using Okhttputils2 to download the same file using a timer.
First I use the following code to check the file size:
Then if the file size is changed I download the file using:
Both these code snippets are in a timer_tick sub:
I have ensured that the timer is disabled after entering the timer sub and again enabling it after the file is downloaded and processed.
But I get intermittent error response as shown below:
The bold part is the content of the file and file size respectively
This error is quite intermittent especially when the file size is larger than 50kb
I am using Okhttputils2 to download the same file using a timer.
First I use the following code to check the file size:
B4X:
Dim dd As DownloadData
dd.url = link1
dd.EventName = "dd"
dd.Target = Me
Dim j As HttpJob
j.Initialize(dd.url, Me)
j.Head(dd.url)
Wait For (j) JobDone(j As HttpJob)
j.Release
Sleep(1000)
If j.Success Then
Dim fs As List=j.Response.GetHeaders.GetValueAt(0)
Dim fsval As Int=fs.Get(0)
Then if the file size is changed I download the file using:
B4X:
Dim J1 As HttpJob
J1.Initialize(dd.url, Me)
Dim tag As JobTag
tag.Initialize
tag.data = dd
J1.tag = tag
jobs.Put(dd.url, J1)
J1.Download(dd.url)
Wait For (J1) JobDone(J1 As HttpJob)
Both these code snippets are in a timer_tick sub:
I have ensured that the timer is disabled after entering the timer sub and again enabling it after the file is downloaded and processed.
But I get intermittent error response as shown below:
B4X:
java.net.ProtocolException: Unexpected status line: 001550 19-12-15 9:02:25 19.82 85.6
at okhttp3.internal.http.StatusLine.parse(StatusLine.java:69)
at okhttp3.internal.http1.Http1Codec.readResponse(Http1Codec.java:191)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:132)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:54)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at okhttp3.RealCall.execute(RealCall.java:63)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:156)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.access$0(OkHttpClientWrapper.java:153)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$ExecuteHelper.run(OkHttpClientWrapper.java:201)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
ResponseError. Reason: java.net.ProtocolException: Unexpected status line: 001550 19-12-15 9:02:25 19.82 85.6, Response: 58267
This error is quite intermittent especially when the file size is larger than 50kb