Giter Club home page Giter Club logo

Comments (18)

kongzue avatar kongzue commented on June 15, 2024

请通过文档:https://github.com/kongzue/BaseOkHttpV3#%E8%AF%B7%E6%B1%82%E8%B6%85%E6%97%B6 设置超时时间,建议设置到更长的时间避免因上传过程慢导致的超时判定

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

设置后报错以下内容

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.

kongzue avatar kongzue commented on June 15, 2024

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

最新版本

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.

Cjiio avatar Cjiio commented on June 15, 2024

求帮忙看看是服务器端的问题还是客户端的问题

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

请尝试增加一个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.

Cjiio avatar Cjiio commented on June 15, 2024

依旧是相同的问题

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

这应该是okHttp底层逻辑,BaseOkHttpV3是基于OkHttp的二次封装,我会继续尝试帮你寻找解决方案

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

需要确认两件事:
1,已经设置BaseOkHttp.TIME_OUT_DURATION到更大值;
2,是否有同时启动多个请求线程;

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

服务器端能接收文件,但BaseOkHttpV3返回timeout,抓包查看有请求数据,无响应,尝试过修改BaseOkHttpV3的超时,服务器端的超时,都不能解决,设置BaseOkHttp.TIME_OUT_DURATION到6000以及更大值,只有一个请求线程,服务器环境Nginx 1.19.8+php7.0

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

由于jCenter已经停止服务,您可能需要更换到jitpack尝试测试版本:
请参考 https://jitpack.io/#kongzue/BaseOkHttpV3/3.2.3.beta1 进行配置
若测试版本也无法解决您的问题请继续留言我会再次尝试其他方案

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

已解决问题,非常感谢
但我所上传的文件不能自动获取到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.

Cjiio avatar Cjiio commented on June 15, 2024
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.

kongzue avatar kongzue commented on June 15, 2024

很抱歉这应该是一个失误导致的,我刚刚提交了一个最新的测试版本 3.2.3.beta2,其中修复了这个问题,并增加了一个方法:

setCustomMimeType(String customMimeType)

现在,默认情况下应当能够正确获取文件的MIME,如果不能或需要自定义,你可以通过这个方法进行设置,请注意,通过方法自定义设置的优先级是大于默认自动获取MIME的。

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

建议文件下载也支持全局 Header 请求头 ,考虑到某些情况下的防盗链设置,需要设置Referer,感谢您的耐心帮助,祝您工作愉快

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

好的,会在下一个测试版加入

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

请更新至 3.2.3.beta3 测试版本,因为之前的代码在更新多个功能后比较混乱,在最新提交的代码中对 okHttpClient 的构建和 Request 的构建进行了重新整理,整理后会统一进行 header、parameter 的设置、拦截器等操作。

from baseokhttpv3.

Cjiio avatar Cjiio commented on June 15, 2024

好的

from baseokhttpv3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.