khushpanchal / Ketch

An Android File downloader library based on WorkManager with pause and resume support.
https://medium.com/@khush.panchal123/ketch-android-file-downloader-library-7369f7b93bd1
395 stars 26 forks source link

App not downloading some videos links #14

Closed hamza0786 closed 1 month ago

hamza0786 commented 1 month ago

Hi app is not downloading some videos every time the download started and then after 20% downlading it stops and then the download failed.this is not happening with all downloads.only some videos it start the download and then in middle it failed. see the video below:

https://github.com/user-attachments/assets/79d2dc91-f97c-4da9-9650-0a680ea2408b

khushpanchal commented 1 month ago

Could you tell what is the failure reason, it will be coming in downloadModel.failureReason, or you can check by putting breakpoint

hamza0786 commented 1 month ago

ok wait

hamza0786 commented 1 month ago

Hi! this is the logcat when download failed:

2024-08-06 20:16:43.421 6930-6958 WM-Processor com.khush.sample I Moving WorkSpec (4d580483-8300-4014-9ba3-d17a8b87073a) to the foreground 2024-08-06 20:16:46.477 6930-6966 WM-Processor com.khush.sample I Moving WorkSpec (4d580483-8300-4014-9ba3-d17a8b87073a) to the foreground 2024-08-06 20:16:47.304 6930-6958 WM-WorkerWrapper com.khush.sample I Worker result FAILURE for Work [ id=4d580483-8300-4014-9ba3-d17a8b87073a, tags={ com.ketch.internal.worker.DownloadWorker, downloads } ] 2024-08-06 20:16:47.323 6930-6930 WM-SystemFgDispatcher com.khush.sample I Stopping foreground service

hamza0786 commented 1 month ago

this is the video link i downloading:

https://player.vimeo.com/progressive_redirect/playback/874986396/container/a6e5411b-0d73-47a4-8db9-65547e553596/4be49682-9490df1c?expires=1723043420&loc=external&session_id=238cfd7eec861dc64a683288c85bae32cc5bf9621722956900&signature=a65492f3fc968ecf77c2a113371c52d2986c42e7eb6ab12208a52dd990a177a8

khushpanchal commented 1 month ago

Let me check and get back.

hamza0786 commented 1 month ago

ok

hamza0786 commented 1 month ago

any fix brother?

hamza0786 commented 1 month ago

i got this in logcat for failure reason:

Failure reason: stream was reset: PROTOCOL_ERROR

khushpanchal commented 1 month ago

It seems like an open issue happening with HTTP2 https://github.com/square/okhttp/issues/3955

I need to check, give me some time.

One workaround will be to use HTTP1.1

In case you have forked the library, inside RetrofitInstance.kt class add protocol field like this

OkHttpClient.Builder().protocols(listOf(Protocol.HTTP_1_1)).build()
hamza0786 commented 1 month ago

Protocol.HTTP_1_2 is giving unresolved refrence so i have replaced it with HTTP_1_1 now its downloading fine. thanks!

khushpanchal commented 1 month ago

I am keeping it open for now

hamza0786 commented 1 month ago

ok!