NetHttpClient和SocketTimeoutException

时间:2018-06-14 08:49:47

标签: android delphi firemonkey androidhttpclient android-httptransport

我有一个通过wifi工作的Android应用程序,只连接到本地服务器。通常情况下,互联网必须非常快,一切都必须正常工作,但我常常有一些SocketTimeoutException

06-14 01:40:38.141: W/System.err(30529): java.net.SocketTimeoutException
06-14 01:40:38.146: W/System.err(30529):    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
06-14 01:40:38.146: W/System.err(30529):    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
06-14 01:40:38.146: W/System.err(30529):    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okio.Okio$2.read(Okio.java:116)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okio.RealBufferedSource.indexOf(RealBufferedSource.java:150)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:97)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:202)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:119)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:798)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:405)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:349)
06-14 01:40:38.146: W/System.err(30529):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getHeaderFieldKey(HttpURLConnectionImpl.java:174)

我无法理解,因为服务器是本地的并且直接连接到wifi rooter。当我看到服务器上的日志时,如果我有SocketTimeoutException,那么我可以看到没有请求到达服务器

SocketTimeoutException非常随机,有时每小时一次,有时甚至更短。有时我没有SocketTimeoutException,但连接建立起来很慢。

任何想法可能是什么原因或我如何调试/找到问题?

0 个答案:

没有答案