liangjingkanji / Net

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

请求失败 #206

Closed breakadmin closed 1 year ago

breakadmin commented 1 year ago

问题描述

杀掉app重启,有时候会请求失败

期望行为

如何复现

多次杀掉app重启

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

截图

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

版本

liangjingkanji commented 1 year ago

请求用的OkHttp, 从未出现过请求不通的bug

请提供请求报错信息

breakadmin commented 1 year ago

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

liangjingkanji commented 1 year ago
  1. 证书问题, 你检查下你的证书
  2. 如果是你说的重启app偶尔会请求失败请反馈给Okhttp官方, 网络连接Net没有插入任何代码
  3. 临时解决: 信任任何证书
breakadmin commented 1 year ago
at com.drake.net.interceptor.NetOkHttpInterceptor.intercept(NetOkHttpInterceptor.kt:105)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
     at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
     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.pick.quickearn.ui.videModel.MainViewModel$getSystemConfig$1$invokeSuspend$$inlined$Get$default$1.invokeSuspend(NetCoroutine.kt:459)
     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
     at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
     at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
    Caused by: java.net.SocketException: Connection reset
     at java.net.SocketInputStream.read(SocketInputStream.java:215)
     at java.net.SocketInputStream.read(SocketInputStream.java:144)
     at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSocket(ConscryptEngineSocket.java:941)
     at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:905)
     at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.access$100(ConscryptEngineSocket.java:727)
     at com.android.org.conscrypt.ConscryptEngineSocket.doHandshake(ConscryptEngineSocket.java:241)
     at com.android.org.conscrypt.ConscryptEngineSocket.startHandshake(ConscryptEngineSocket.java:220)
     at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
     at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
     at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
     at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
     at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
     at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
     at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
     at com.drake.net.interceptor.NetOkHttpInterceptor.intercept(NetOkHttpInterceptor.kt:89)
     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
     at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221) 
     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.pick.quickearn.ui.videModel.MainViewModel$getSystemConfig$1$invokeSuspend$$inlined$Get$default$1.invokeSuspend(NetCoroutine.kt:459) 
     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 
     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 
     at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) 
     at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) 
     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) 
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) 
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) 
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 
liangjingkanji commented 1 year ago
  1. 你用OkHttp原始请求试下吧, 这和Net没有关系
  2. 你们公司后端写的有问题, 强制关流了
liangjingkanji commented 1 year ago

如果坚持认为Net有问题, 但是不太想追溯问题(本框架属于开源项目), 可以换Retrofit或者Okhttp

考虑到本问题毫无进展, 我将暂时关闭此问题