关闭代理连接后,Okhttp发送http请求

问题描述 投票:0回答:1

我正在通过代理传输请求,好像它每10-15秒就会关闭一次连接。因此,如果客户端请求一个网站,并且花费一些时间,则连接可能会关闭,因此okhttp库将引发“流的意外末尾”。即使连接已关闭并且库引发该异常,服务器也已成功接收到请求,但客户端无法检查答案。如果我尝试在不使用代理的情况下请求相同的网址,则没有问题,并且我成功收到了答案。在这里,您可以看到它wireshark:wireshark capture

在照片中,您最终可以看到客户端在19:27:54,980发出的请求,然后在10秒钟后,客户端收到FIN tcp数据包。因此,在此之后,Okhttp会引发此异常:

java.io.IOException: unexpected end of stream on Connection{m.apuestas.codere.es:443, proxy=HTTP @ /185.163.232.127:58542 hostAddress=/185.163.232.127:58542 cipherSuite=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA protocol=http/1.1}
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at com.telecobets.http.HTTPClient$LoggingInterceptor.intercept(HTTPClient.java:219)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at com.telecobets.http.HTTPClient$AddHeadersInterceptor.intercept(HTTPClient.java:199)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:188)
at com.main(Main.java:375)
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:237)
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
... 26 more

不是关闭连接的服务器,因为我同时对不同的服务器执行了不同的请求,并且突然同时关闭了连接。所以我的问题是,即使代理服务器关闭了连接,有没有办法接收到该答案?

整个wireshark捕获为here

代理IP:185.163.232.127:58542

java proxy okhttp
1个回答
0
投票

代理服务器提供者每10秒断开一次连接。

© www.soinside.com 2019 - 2024. All rights reserved.