majidgolshadi / Android-Download-Manager-Pro

Android/Java download manager library help you to download files in parallel mechanism in some chunks.
MIT License
1.61k stars 317 forks source link

java.net.SocketTimeoutException #5

Closed oneenam closed 9 years ago

oneenam commented 9 years ago
System.err﹕ java.net.SocketTimeoutException
System.err﹕ at java.net.PlainSocketImpl.read(PlainSocketImpl.java:491)
System.err﹕ at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
System.err﹕ at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
System.err﹕ at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
System.err﹕ at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
System.err﹕ at java.io.InputStream.read(InputStream.java:163)
System.err﹕ at com.golshadi.majid.core.chunkWorker.AsyncWorker.run(AsyncWorker.java:64)

for the first time downloaded properly...after then always getting this error...why?

majidgolshadi commented 9 years ago

This error occur when worker (chunk downloader) can't get any data from target server. Did you test your code with another server?

oneenam commented 9 years ago

target server response is ok. checked and tested target server response.

once this error start then again and again this exception shows until uninstall the app and newly install it. with fresh install it works. if lost connection arise then it should retry or clean previous stuffs as if 2nd time it should start as fresh!

majidgolshadi commented 9 years ago

I use this library in some applications and i don't have any problem like this. So i have to focus on this issue and find-out why this happen. Would you please help me more to find-out the reason of this problem?

oneenam commented 9 years ago

next time when i will get same problem i will post the exception with log. thanks for the nice lib.

majidgolshadi commented 9 years ago

Thank you I'm waiting for

oneenam commented 9 years ago

again happened :( but this time only once...after then again started working... here is the log that i posted before....is there any function to increase waiting time...or if connection lost then how can I call start process?

/Download﹕ onDownloadProcess: percent: 12.575080871582031 downloadedLength: 2726466
/System.err﹕ java.net.SocketTimeoutException
/System.err﹕ at java.net.PlainSocketImpl.read(PlainSocketImpl.java:491)
/System.err﹕ at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
/System.err﹕ at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
/System.err﹕ at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
/System.err﹕ at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
/System.err﹕ at java.io.InputStream.read(InputStream.java:163)
/System.err﹕ at com.golshadi.majid.core.chunkWorker.AsyncWorker.run(AsyncWorker.java:64)
/Download﹕ connectionLost: 1
/--------﹕ raw query
/--------﹕ cr close
suleymanccelik commented 9 years ago

Hi, Can you increase HttpURLConnection timeouts on asyncworker class?

HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(2000); connection.setReadTimeout(5000);

oneenam commented 9 years ago

wooow...thanks for ur quick response...let me try by increasing it.....i am downloading 25mb size file...i will let u know...thanks

farzad119 commented 9 years ago

I have the same problem, i increased timeouts value and now working with resumable links. but when i download an unresumable link, only about 10 percentage of my file download! What ideas do you have? (sry for my bad ENG ;) )

suleymanccelik commented 9 years ago

Resume capability depends on the server from which you are downloading the file. Do you have a chance to change server configuration? I think, unresumable link issue is not related with that project.

farzad119 commented 9 years ago

for example this is a unresumable link: f.apk4fun.com/f.php?p=869... i can download this link with IDM and ADM without problem but when i want download this link with this lib i get timeout error in log and my download has stopped.

ASPOOK commented 9 years ago

I have the same problem , error log:

/AN﹕ onDownloadProcess,taskid:18,percent:7.520145416259766,downloadedLenth:883995
/AN﹕ onDownloadProcess,taskid:18,percent:7.699812889099121,downloadedLenth:905115
/System.err﹕ java.net.SocketTimeoutException
/System.err﹕ at java.net.PlainSocketImpl.read(PlainSocketImpl.java:492)
/System.err﹕ at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
/System.err﹕ at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241)
/System.err﹕ at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
/System.err﹕ at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
/System.err﹕ at java.io.InputStream.read(InputStream.java:163)
/System.err﹕ at com.golshadi.majid.core.chunkWorker.AsyncWorker.run(AsyncWorker.java:64)
/AN﹕ connectionLost,taskid:18
/--------﹕ raw query
/--------﹕ cr close
/AN﹕ OnDownloadPaused,taskid:18
/System.err﹕ java.net.SocketTimeoutException
/System.err﹕ at java.net.PlainSocketImpl.read(PlainSocketImpl.java:492)
/System.err﹕ at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
/System.err﹕ at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241)
/System.err﹕ at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
/System.err﹕ at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
/System.err﹕ at java.io.InputStream.read(InputStream.java:163)
/System.err﹕ at com.golshadi.majid.core.chunkWorker.AsyncWorker.run(AsyncWorker.java:64)
/AN﹕ connectionLost,taskid:18
/--------﹕ raw query
/--------﹕ cr close
/AN﹕ connectionLost,taskid:17
/--------﹕ raw query
/--------﹕ cr close

I'm trying to dowoload an apk file,about 10M and found this problem;I had tried a lot of times,this problem occured everytime.the download file url is: http://gdown.baidu.com/data/wisegame/91319a5a1dfae322/baidu_16785426.apk

when i increase the timeout in AsyncWorker class,but it dosen't work. I try to download a samll jpg with 371k and it success.


after some tests, the "SocketTimeoutException" may be solved by increasing the HttpURLConnection's timeout. But it will occur"connectionLost" when in downloading process without the "SocketTimeoutException" some times.

llitfkitfk commented 9 years ago

just increase the Timeout in AsyncWorker