liangjingkanji / Net

Android 基于协程/OkHttp网络请求工具
http://liangjingkanji.github.io/Net/
MIT License
1.9k stars 214 forks source link

java.net.ProtocolException: unexpected end of stream #222

Closed Xiaolangs closed 8 months ago

Xiaolangs commented 9 months ago

问题描述

上传文件过大

java.net.ProtocolException: unexpected end of stream at okhttp3.internal.http1.Http1ExchangeCodec$FixedLengthSource.read(Http1ExchangeCodec.kt:379) at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:281) at okio.RealBufferedSource.read(RealBufferedSource.kt:192) at okio.ForwardingSource.read(ForwardingSource.kt:27) at com.drake.net.body.NetResponseBody$toProgress$1.read(NetResponseBody.kt:63) at okio.RealBufferedSource.request(RealBufferedSource.kt:209) at okio.PeekSource.read(PeekSource.kt:50) at okio.RealBufferedSource.request(RealBufferedSource.kt:209) at okhttp3.Response.peekBody(Response.kt:197) at com.localebro.okhttpprofiler.transfer.LogDataTransfer.sendResponse(LogDataTransfer.java:83) at com.localebro.okhttpprofiler.OkHttpProfilerInterceptor.intercept(OkHttpProfilerInterceptor.java:35) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at com.xiaolang.nexbotx.MainActivity$iniView$3$1$1$1$1$invokeSuspend$$inlined$Post$default$1.invokeSuspend(NetCoroutine.kt:222) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

期望行为

如何复现

fork仓库并复现问题可以快速解决, 猜测只会让问题晦涩难懂, 耽误所有人时间

截图

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

liangjingkanji commented 9 months ago

看情况是被服务器结束了流 你试下搜索 Okhttp+异常,Net并不未修改OkHttp的网络层

Xiaolangs commented 9 months ago

看情况是被服务器结束了流 你试下搜索 Okhttp+异常,Net并不未修改OkHttp的网络层

服务端我是的ktor 通过apifox 请求正常,是否ktor有相关的文件大小链接超时的配置吗?

liangjingkanji commented 8 months ago

搜索下就知道原因了