lingochamp / lingochamp/FileDownloader

java.net.ProtocolException: unexpected end of stream

Open
#1,355 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
11.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

#### 报错信息
`
java.net.ProtocolException: unexpected end of stream
at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:398)
at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:372)
at java.io.InputStream.read(InputStream.java:101)
at com.liulishuo.filedownloader.download.FetchDataTask.run(FetchDataTask.java:141)
at com.liulishuo.filedownloader.download.DownloadRunnable.run(DownloadRunnable.java:121)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)
`
version: 1.7.7

### log
`
I/FileDownloader.FileDownloadProperties: init properties 1
load properties: http.lenient=FALSE; process.non-separate=TRUE; download.min-progress-step=65536; download.min-progress-time=2000; download.max-network-thread-count=3; file.non-pre-allocation=FALSE; broadcast.completed=FALSE; download.trial-connection-head-method=FALSE
D/FileDownloader.LostServiceConnectedHandler: Waiting for connecting with the downloader service... 902999258
D/FileDownloader.DownloadTaskHunter: free the task 902999258, when the status is 10
D/FileDownloader.FileDownloadDatabase: refreshed data count: 0 , delete data count: 0, reset id count: 0. consume 1
V/FileDownloader.FileDownloadEventPool: asyncPublishInNewThread event.service.connect.changed
V/FileDownloader.FileDownloadEventPool: publish event.service.connect.changed
D/FileDownloader.LostServiceConnectedHandler: The downloader service is connected.
V/FileDownloader.DownloadTaskHunter: call start Url[https://static.quanminshike.com/apk/lqsw/releases/com.lqsw.duowanenvelope_base_2.1.7.apk], Path[/storage/emulated/0/lqsw/download/com.lqsw.duowanenvelope_base_2.1.7.apk] Listener[com.lqsw.duowanenvelope.view.dialog.UpdateDialogFragment$updateVersion$baseDownloadTask$1@5c8a4f0], Tag[null]
V/FileDownloader.DownloadTaskHunter: the task[902999258] has been into the launch pool.
D/FileDownloader.FileDownloadMessenger: notify begin 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9
V/FileDownloader.DownloadTaskHunter: filedownloader:lifecycle:start com.liulishuo.filedownloader.DownloadTaskHunter@7e39d9e by 11
V/FileDownloader.FileDownloadList: add list in all 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 11 1
D/FileDownloader.FileDownloadManager: request start the task with url(https://static.quanminshike.com/apk/lqsw/releases/com.lqsw.duowanenvelope_base_2.1.7.apk) path(/storage/emulated/0/lqsw/download/com.lqsw.duowanenvelope_base_2.1.7.apk) isDirectory(FALSE)
D/FileDownloader.FileDownloadUtils: can't continue 902999258 file not suit, exists[FALSE], directory[FALSE]
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[11] new[1] 1
D/FileDownloader.FileDownloadMessenger: notify pending 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[1] new[6] 1
D/FileDownloader.FileDownloadMessenger: notify started 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
V/FileDownloader.ConnectTask: 902999258 add outside header: {Connection=[keep-alive]}
D/FileDownloader.ConnectTask: <---- 902999258 request header {Connection=[keep-alive], Range=[bytes=0-0], User-Agent=[FileDownloader/1.7.7]}
D/FileDownloader.ConnectTask: ----> 902999258 response header {null=[HTTP/1.1 206 Partial Content], Accept-Ranges=[bytes], Age=[0], Ali-Swift-Global-Savetime=[1596609907], Connection=[keep-alive], Content-Length=[1], Content-MD5=[dZXfX5kmZbGhkyaH96GZhw==], Content-Range=[bytes 0-0/18080792], Content-Type=[application/vnd.android.package-archive], Date=[Thu, 06 Aug 2020 09:44:28 GMT], EagleId=[7160b59e15967070687135380e], ETag=["7595DF5F992665B1A1932687F7A19987"], Last-Modified=[Wed, 05 Aug 2020 06:40:12 GMT], Server=[Tengine], Timing-Allow-Origin=[*], Vary=[Origin], Via=[cache14.l2cn1823[25,304-0,H], cache16.l2cn1823[37,0], cache16.cn1368[143,206-0,H], cache10.cn1368[148,0]], X-Android-Received-Millis=[1596707065105], X-Android-Response-Source=[NETWORK 206], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1596707064942], X-Cache=[HIT TCP_REFRESH_HIT dirn:13:49229437], x-oss-cdn-auth=[success], x-oss-hash-crc64ecma=[7633098847487272055], x-oss-object-type=[Normal], x-oss-request-id=[5F2BD0FC5820623232C09082], x-oss-server-time=[7], x-oss-storage-class=[Standard], X-Swift-CacheTime=[3600], X-Swift-SaveTime=[Thu, 06 Aug 2020 09:44:28 GMT]}
D/FileDownloader.FileDownloadUtils: etag find "7595DF5F992665B1A1932687F7A19987" for task(902999258)
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[6] new[2] 1
D/FileDownloader.FileDownloadMessenger: notify connected 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9
D/FileDownloader.FileDownloadUtils: can't continue 902999258 file not suit, exists[FALSE], directory[FALSE]
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.DownloadLaunchRunnable: fetch data with multiple connection(count: [3]) for task[902999258] totalLength[18080792]
D/FileDownloader.DownloadLaunchRunnable: enable multiple connection: id[902999258] index[0] range[0, 6026929) current offset(0)
D/FileDownloader.DownloadLaunchRunnable: enable multiple connection: id[902999258] index[1] range[6026930, 12053859) current offset(6026930)
D/FileDownloader.DownloadLaunchRunnable: enable multiple connection: id[902999258] index[2] range[12053860, -1) current offset(12053860)
V/FileDownloader.ConnectTask: 902999258 add outside header: {Connection=[keep-alive]}
D/FileDownloader.ConnectTask: <---- 902999258 request header {Connection=[keep-alive], Range=[bytes=0-6026929], User-Agent=[FileDownloader/1.7.7]}
V/FileDownloader.ConnectTask: 902999258 add outside header: {Connection=[keep-alive]}
D/FileDownloader.ConnectTask: <---- 902999258 request header {Connection=[keep-alive], Range=[bytes=12053860-], User-Agent=[FileDownloader/1.7.7]}
V/FileDownloader.ConnectTask: 902999258 add outside header: {Connection=[keep-alive]}
D/FileDownloader.ConnectTask: <---- 902999258 request header {Connection=[keep-alive], Range=[bytes=6026930-12053859], User-Agent=[FileDownloader/1.7.7]}
D/FileDownloader.ConnectTask: ----> 902999258 response header {null=[HTTP/1.1 206 Partial Content], Accept-Ranges=[bytes], Age=[0], Ali-Swift-Global-Savetime=[1596609907], Connection=[keep-alive], Content-Length=[6026930], Content-MD5=[dZXfX5kmZbGhkyaH96GZhw==], Content-Range=[bytes 0-6026929/18080792], Content-Type=[application/vnd.android.package-archive], Date=[Thu, 06 Aug 2020 09:44:28 GMT], EagleId=[7160b59e15967070688826350e], ETag=["7595DF5F992665B1A1932687F7A19987"], Last-Modified=[Wed, 05 Aug 2020 06:40:12 GMT], Server=[Tengine], Timing-Allow-Origin=[*], Vary=[Origin], Via=[cache14.l2cn1823[25,304-0,H], cache16.l2cn1823[37,0], cache16.cn1368[0,206-0,H], cache10.cn1368[2,0]], X-Android-Received-Millis=[1596707065133], X-Android-Response-Source=[NETWORK 206], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1596707065114], X-Cache=[HIT TCP_MEM_HIT dirn:13:49229437], x-oss-cdn-auth=[success], x-oss-hash-crc64ecma=[7633098847487272055], x-oss-object-type=[Normal], x-oss-request-id=[5F2BD0FC5820623232C09082], x-oss-server-time=[7], x-oss-storage-class=[Standard], X-Swift-CacheTime=[3600], X-Swift-SaveTime=[Thu, 06 Aug 2020 09:44:28 GMT]}
D/FileDownloader.DownloadRunnable: the connection[0] for 902999258, is connected range[0, 6026929) current offset[0] with code[206]
D/FileDownloader.FetchDataTask: start fetch(0): range [0, 6026929), seek to[0]
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress update model's status with progress
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[2] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 6105 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[0] offset[66857], consume[2]
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 193429 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 370508 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 550608 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.ConnectTask: ----> 902999258 response header {null=[HTTP/1.1 206 Partial Content], Accept-Ranges=[bytes], Age=[1], Ali-Swift-Global-Savetime=[1596609907], Connection=[keep-alive], Content-Length=[6026930], Content-MD5=[dZXfX5kmZbGhkyaH96GZhw==], Content-Range=[bytes 6026930-12053859/18080792], Content-Type=[application/vnd.android.package-archive], Date=[Thu, 06 Aug 2020 09:44:28 GMT], EagleId=[7160b5a115967070691813127e], ETag=["7595DF5F992665B1A1932687F7A19987"], Last-Modified=[Wed, 05 Aug 2020 06:40:12 GMT], Server=[Tengine], Timing-Allow-Origin=[*], Vary=[Origin], Via=[cache14.l2cn1823[25,304-0,H], cache16.l2cn1823[37,0], cache16.cn1368[0,206-0,H], cache13.cn1368[2,0]], X-Android-Received-Millis=[1596707065448], X-Android-Response-Source=[NETWORK 206], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1596707065220], X-Cache=[HIT TCP_MEM_HIT dirn:13:49229437], x-oss-cdn-auth=[success], x-oss-hash-crc64ecma=[7633098847487272055], x-oss-object-type=[Normal], x-oss-request-id=[5F2BD0FC5820623232C09082], x-oss-server-time=[7], x-oss-storage-class=[Standard], X-Swift-CacheTime=[3600], X-Swift-SaveTime=[Thu, 06 Aug 2020 09:44:28 GMT]}
D/FileDownloader.DownloadRunnable: the connection[1] for 902999258, is connected range[6026930, 12053859) current offset[6026930] with code[206]
D/FileDownloader.FetchDataTask: start fetch(1): range [6026930, 12053859), seek to[6026930]
D/FileDownloader.ConnectTask: ----> 902999258 response header {null=[HTTP/1.1 206 Partial Content], Accept-Ranges=[bytes], Age=[1], Ali-Swift-Global-Savetime=[1596609907], Connection=[keep-alive], Content-Length=[6026932], Content-MD5=[dZXfX5kmZbGhkyaH96GZhw==], Content-Range=[bytes 12053860-18080791/18080792], Content-Type=[application/vnd.android.package-archive], Date=[Thu, 06 Aug 2020 09:44:28 GMT], EagleId=[7160b59f15967070691852558e], ETag=["7595DF5F992665B1A1932687F7A19987"], Last-Modified=[Wed, 05 Aug 2020 06:40:12 GMT], Server=[Tengine], Timing-Allow-Origin=[*], Vary=[Origin], Via=[cache14.l2cn1823[25,304-0,H], cache16.l2cn1823[37,0], cache16.cn1368[0,206-0,H], cache11.cn1368[1,0]], X-Android-Received-Millis=[1596707065449], X-Android-Response-Source=[NETWORK 206], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1596707065225], X-Cache=[HIT TCP_MEM_HIT dirn:13:49229437], x-oss-cdn-auth=[success], x-oss-hash-crc64ecma=[7633098847487272055], x-oss-object-type=[Normal], x-oss-request-id=[5F2BD0FC5820623232C09082], x-oss-server-time=[7], x-oss-storage-class=[Standard], X-Swift-CacheTime=[3600], X-Swift-SaveTime=[Thu, 06 Aug 2020 09:44:28 GMT]}
D/FileDownloader.DownloadRunnable: the connection[2] for 902999258, is connected range[12053860, -1) current offset[12053860] with code[206]
D/FileDownloader.FetchDataTask: start fetch(2): range [12053860, -1), seek to[12053860]
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[2] offset[12057956], consume[5]
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[1] offset[6031026], consume[2]
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 734096 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 1000336 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 1192848 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 1373072 18080792
.
.
省略中间部分
.
.
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 14966148 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[1] offset[12053860], consume[3]
D/FileDownloader.DownloadLaunchRunnable: the connection has been completed(1): [6026930, 12053859) 18080792
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[0] offset[3090128], consume[4]
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 15156278 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[0] offset[3159760], consume[4]
I/FileDownloader.DownloadStatusCallback: inspectNeedCallbackToUser need callback to user
I/FileDownloader.DownloadStatusCallback: handleProgress notify user progress status
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[3] 1
D/FileDownloader.FileDownloadMessenger: notify progress 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 15336502 18080792
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
D/FileDownloader.FetchDataTask: require flushAndSync id[902999258] index[0] offset[3413712], consume[5]
D/FileDownloader.DownloadLaunchRunnable: finish sub-task for [902999258] TRUE FALSE
I/chatty: uid=10390(com.lqsw.duowanenvelope) FileDownloader- identical 1 line
D/FileDownloader.DownloadLaunchRunnable: finish sub-task for [902999258] TRUE FALSE
D/FileDownloader.MessageSnapshotGate: ~~~callback 902999258 old[3] new[-1] 1
V/FileDownloader.FileDownloadList: remove 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 left -1 0
D/FileDownloader.FileDownloadMessenger: notify error 902999258@com.liulishuo.filedownloader.DownloadTask@622dfd9 java.net.ProtocolException: unexpected end of stream
V/FileDownloader.DownloadTaskHunter: filedownloader:lifecycle:over com.liulishuo.filedownloader.DownloadTaskHunter@7e39d9e by -1
D/FileDownloader.MessageSnapshotGate: updateKeepFlow
W/FileDownloader.FileDownloader: request pause but not exist 902999258

`
不是必现,但在一台Android手机上复现几率达90%,基本都是一样的问题,下载一部分就不下载了,然后就任务失败了。别的手机暂时没发现这个问题。
看了很多人的帖子,什么添加Header都没有用,issues里感觉都没人解决这个问题,基本都是说服务端问题,文件是在阿里云上的,[文件地址](https://static.quanminshike.com/apk/lqsw/releases/com.lqsw.duowanenvelope_base_2.1.7.apk)
,求大佬帮忙看看,该怎么处理。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the logged failure through com.android.okhttp.internal.http.Http1xStream, FetchDataTask.java, and DownloadRunnable.java, using the logged URL and multi-connection ranges. Compare the response Content-Length and Content-Range values with the read offsets; the issue does not define a desired fix or acceptance condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.