Comments (18)
请通过文档:https://github.com/kongzue/BaseOkHttpV3#%E8%AF%B7%E6%B1%82%E8%B6%85%E6%97%B6 设置超时时间,建议设置到更长的时间避免因上传过程慢导致的超时判定
from baseokhttpv3.
设置后报错以下内容
I/>>>: addRequestInfo: RequestInfo{url='http://app.ygink.cn/api.php?app=10000&act=upload', parameter='archive_md5=4ov5m9uk9fu8ehmh6lbqrbj2lm&bz=5855556&cdname=kfkfkdkdkkdkdfk.wld&file=/storage/emulated/0/yyg/.tmp/wld/kfkfkdkdkkdkdfk.wld&t=1618766019959&token=fd50260c72dcd5098a7fdf4862232199&type=bak'}
I/>>>: 添加文件:file:kfkfkdkdkkdkdfk.wld
I/>>>: 添加请求头:
I/>>>>>>: Charset=UTF-8
I/>>>>>>: Referer=yyg
I/>>>: -------------------------------------
I/>>>: 创建请求:http://app.ygink.cn/api.php?app=10000&act=upload
I/>>>: 参数:
I/>>>>>>: archive_md5=4ov5m9uk9fu8ehmh6lbqrbj2lm&bz=5855556&cdname=kfkfkdkdkkdkdfk.wld&file=/storage/emulated/0/yyg/.tmp/wld/kfkfkdkdkkdkdfk.wld&t=1618766019959&token=fd50260c72dcd5098a7fdf4862232199&type=bak
I/>>>: 请求已发送 ->
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@8b0ca46[MainActivity]
V/ViewRootImpl: The specified message queue synchronization barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in com.ygink.cn/com.ygink.cn.activity.MainActivity
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@5145173[MainActivity]
W/Choreographer: Already have a pending vsync event. There should only be one at a time.
E/>>>: 请求失败:http://app.ygink.cn/api.php?app=10000&act=upload
E/>>>: 参数:
E/>>>>>>: archive_md5=4ov5m9uk9fu8ehmh6lbqrbj2lm&bz=5855556&cdname=kfkfkdkdkkdkdfk.wld&file=/storage/emulated/0/yyg/.tmp/wld/kfkfkdkdkkdkdfk.wld&t=1618766019959&token=fd50260c72dcd5098a7fdf4862232199&type=bak
E/>>>: 错误:java.net.SocketTimeoutException: timeout
at baseokio.Okio$4.newTimeoutException(Okio.java:226)
at baseokio.AsyncTimeout.exit(AsyncTimeout.java:226)
at baseokio.AsyncTimeout$2.read(AsyncTimeout.java:186)
at baseokio.RealBufferedSource.indexOf(RealBufferedSource.java:380)
at baseokio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:255)
at baseokhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:223)
at baseokhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:197)
at baseokhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:90)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:47)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:95)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:95)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:129)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:209)
at baseokhttp3.RealCall$AsyncCall.execute(RealCall.java:156)
at baseokhttp3.internal.NamedRunnable.run(NamedRunnable.java:33)
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:919)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:144)
at baseokio.Okio$2.read(Okio.java:120)
at baseokio.AsyncTimeout$2.read(AsyncTimeout.java:182)
at baseokio.RealBufferedSource.indexOf(RealBufferedSource.java:380)
at baseokio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:255)
at baseokhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:223)
at baseokhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:197)
at baseokhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:90)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:47)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:95)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:95)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:129)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:158)
at baseokhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:132)
at baseokhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:209)
at baseokhttp3.RealCall$AsyncCall.execute(RealCall.java:156)
at baseokhttp3.internal.NamedRunnable.run(NamedRunnable.java:33)
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:919)
E/>>>: =====================================
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@8b0ca46[MainActivity]
V/ViewRootImpl: The specified message queue synchronization barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in Toast
from baseokhttpv3.
from baseokhttpv3.
最新版本
D/OpenGLRenderer: endAllActiveAnimators on 0x7c646ffe10 (ListView) with handle 0x7b8464a6b0
I/>>>: addRequestInfo: RequestInfo{url='http://app.ygink.cn/api.php?app=10000&act=upload', parameter='archive_md5=40fvh1fsg6ema6kfohnqc4pfoe&bz=dkdkfff&cdname=bin.mt.plus.plr&file=/storage/emulated/0/yyg/.tmp/wld/bin.mt.plus.plr&t=1618835061087&token=be1b9116c7a837db69bef1dadd546e57&type=bak'}
I/>>>: 添加文件:file:bin.mt.plus.plr
I/>>>: 添加请求头:
I/>>>>>>: Charset=UTF-8
I/>>>>>>: Referer=yyg
I/>>>: -------------------------------------
I/>>>: 创建请求:http://app.ygink.cn/api.php?app=10000&act=upload
I/>>>: 参数:
I/>>>>>>: archive_md5=40fvh1fsg6ema6kfohnqc4pfoe&bz=dkdkfff&cdname=bin.mt.plus.plr&file=/storage/emulated/0/yyg/.tmp/wld/bin.mt.plus.plr&t=1618835061087&token=be1b9116c7a837db69bef1dadd546e57&type=bak
I/>>>: 请求已发送 ->
E/>>>: 请求失败:http://app.ygink.cn/api.php?app=10000&act=upload
E/>>>: 参数:
E/>>>>>>: archive_md5=40fvh1fsg6ema6kfohnqc4pfoe&bz=dkdkfff&cdname=bin.mt.plus.plr&file=/storage/emulated/0/yyg/.tmp/wld/bin.mt.plus.plr&t=1618835061087&token=be1b9116c7a837db69bef1dadd546e57&type=bak
E/>>>: 错误:java.net.SocketTimeoutException: timeout
at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:146)
at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:158)
at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:337)
at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
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 okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
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:923)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:144)
at okio.InputStreamSource.read(JvmOkio.kt:93)
at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:125)
at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
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 okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
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:923)
E/>>>: =====================================
from baseokhttpv3.
求帮忙看看是服务器端的问题还是客户端的问题
from baseokhttpv3.
请尝试增加一个Header:
范例代码如下:
HttpRequest.build(context,"url")
.addHeaders("Connection", "keep-alive")
.addParameter("key","value")
.setJsonResponseListener(new JsonResponseListener() {
@Override
public void onResponse(JsonMap main, Exception error) {
//To do...
}
})
.doPost();
from baseokhttpv3.
依旧是相同的问题
from baseokhttpv3.
这应该是okHttp底层逻辑,BaseOkHttpV3是基于OkHttp的二次封装,我会继续尝试帮你寻找解决方案
from baseokhttpv3.
需要确认两件事:
1,已经设置BaseOkHttp.TIME_OUT_DURATION到更大值;
2,是否有同时启动多个请求线程;
from baseokhttpv3.
服务器端能接收文件,但BaseOkHttpV3返回timeout,抓包查看有请求数据,无响应,尝试过修改BaseOkHttpV3的超时,服务器端的超时,都不能解决,设置BaseOkHttp.TIME_OUT_DURATION到6000以及更大值,只有一个请求线程,服务器环境Nginx 1.19.8+php7.0
from baseokhttpv3.
由于jCenter已经停止服务,您可能需要更换到jitpack尝试测试版本:
请参考 https://jitpack.io/#kongzue/BaseOkHttpV3/3.2.3.beta1 进行配置
若测试版本也无法解决您的问题请继续留言我会再次尝试其他方案
from baseokhttpv3.
已解决问题,非常感谢
但我所上传的文件不能自动获取到MIME,报错空指针,有什么方法能够自定义上传文件的MIME
在之前得版本中我是将
public static String getMimeType(File file) {
String suffix = getSuffix(file);
if (suffix == null) {
return "file/";
}
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix);
if (type != null || !type.isEmpty()) {
return type;
}
return "file/";
}
中 || !type.isEmpty()去除但现在测试版本我不能够修改
from baseokhttpv3.
I/>>>: addRequestInfo: RequestInfo{url='http://app.ygink.cn/api.php?app=10000&act=upload', parameter='archive_md5=26j4gllfsofs93pblqdgs4g765&bz=显卡大口大口&cdname=飞康达快递看.wld&file=/storage/emulated/0/yyg/.tmp/wld/飞康达快递看.wld&t=1618849230092&token=3af47d63a32ca55db51c30320a6ee484&type=bak'}
E/>>>: 请求创建失败:http://app.ygink.cn/api.php?app=10000&act=upload
E/>>>: 参数:
E/>>>>>>: archive_md5=26j4gllfsofs93pblqdgs4g765&bz=显卡大口大口&cdname=飞康达快递看.wld&file=/storage/emulated/0/yyg/.tmp/wld/飞康达快递看.wld&t=1618849230092&token=3af47d63a32ca55db51c30320a6ee484&type=bak
E/>>>: 错误:java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
at com.kongzue.baseokhttp.HttpRequest.getMimeType(HttpRequest.java:735)
at com.kongzue.baseokhttp.HttpRequest.send(HttpRequest.java:377)
at com.kongzue.baseokhttp.HttpRequest.doPost(HttpRequest.java:1223)
at com.ygink.cn.fragment.Hanagment_tab_2.lambda$cloud_bak$4$Hanagment_tab_2(Hanagment_tab_2.java:212)
at com.ygink.cn.fragment.-$$Lambda$Hanagment_tab_2$HCUTR7eZgvRmvvR7eoXnztaGOiQ.onClick(Unknown Source:11)
at com.kongzue.dialog.v3.InputDialog$4.onClick(InputDialog.java:316)
at android.view.View.performClick(View.java:7201)
at android.view.View.performClickInternal(View.java:7170)
at android.view.View.access$3500(View.java:806)
at android.view.View$PerformClick.run(View.java:27582)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/>>>: =====================================
D/OnePlusJankManager: Chor uploadMDM JANK_TYPE_ONCE mViewTitle = com.ygink.cn/com.ygink.cn.activity.MainActivity--- jank level = 1
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@12f6df[MainActivity]
V/ViewRootImpl: The specified message queue synchronization barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in com.ygink.cn/com.ygink.cn.activity.MainActivity
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@d043e68[MainActivity]
W/Choreographer: Already have a pending vsync event. There should only be one at a time.
from baseokhttpv3.
很抱歉这应该是一个失误导致的,我刚刚提交了一个最新的测试版本 3.2.3.beta2,其中修复了这个问题,并增加了一个方法:
setCustomMimeType(String customMimeType)
现在,默认情况下应当能够正确获取文件的MIME,如果不能或需要自定义,你可以通过这个方法进行设置,请注意,通过方法自定义设置的优先级是大于默认自动获取MIME的。
from baseokhttpv3.
建议文件下载也支持全局 Header 请求头 ,考虑到某些情况下的防盗链设置,需要设置Referer,感谢您的耐心帮助,祝您工作愉快
from baseokhttpv3.
好的,会在下一个测试版加入
from baseokhttpv3.
请更新至 3.2.3.beta3 测试版本,因为之前的代码在更新多个功能后比较混乱,在最新提交的代码中对 okHttpClient 的构建和 Request 的构建进行了重新整理,整理后会统一进行 header、parameter 的设置、拦截器等操作。
from baseokhttpv3.
好的
from baseokhttpv3.
Related Issues (20)
- 对于post 请求 Query Params方式传参?怎么传? HOT 5
- 文件POST上传 HOT 3
- 文件下载建议
- 建议增加 请求错误码统一处理 HOT 1
- kotlin冲突了,怎么排除内部依赖的kotlin-stdlib这个依赖 HOT 2
- 关于文件上传,设置全局请求拦截
- 关于文件下载
- 你好 请问如何返回字节应该怎么处理呢
- 你好,选择了某些文件后点击上传按钮就没反应 HOT 1
- 你好 问下 我mvvm模式 viewmodel里面不适合传入context 请问操作 HOT 3
- 跳过SSL认证
- 文件下载地址若失效,会走onDownloadSuccess回调
- 上传问题 HOT 1
- 内存泄漏
- 本人小白,不太懂如何解析response,希望大神能教一下。 HOT 2
- websocket HOT 6
- https
- 怎么跳过SSL证书验证,build.skipSSLCheck();这个方法无效
- websocket问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baseokhttpv3.