0

I have a problem and I don't know how to get rid of it. Sometimes (that's the main problem, it's just sometimes) I have this exception :

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

I know what is basically a socketTimeoutException, but here the problem is that it can't happen (or at least not so much) as the server is local and connected to the same router where the phone is connected (I tried with a different router, same problem). And off course the server is working perfectly (When i have an error in the app the log on the server show that the server never receive any request). So what can make that I have sometimes (2 - 10 times per day) a java.net.SocketTimeoutException that I can't reproduce (just trying again the exact same request and it's work fine).

I m using delphi TNetHttpClient (don't know if it's matter) that internally use HttpURLConnection

Also what can I do to debug this error to find what is the real reason of the java.net.SocketTimeoutException ?

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
zeus
  • 12,173
  • 9
  • 63
  • 184
  • https://airbrake.io/blog/java-exception-handling/sockettimeoutexception check this , if this helps – Anjani Mittal Jul 23 '18 at 08:56
  • @AnjaniMittal thanks unfortunatly this article is too much generic to socket it's didn't help :( I don't use socket directly, just by httpUrlConnection, my problem is to understand what cause the socket timeout because is surely in the software not in hardware/network – zeus Jul 23 '18 at 09:18
  • 1
    Is this happening on one particular device, or more than one? – Dave Nottage Jul 23 '18 at 10:14
  • Also, you might like to look at: https://stackoverflow.com/questions/9094227/httpurlconnection-error-java-net-sockettimeoutexception-connection-timed-out. They talk about a "close" method, but I can't seem to find any. Changing the read timeout perhaps might help? – Dave Nottage Jul 23 '18 at 10:26
  • @DaveNottage: it's happening in several device, but only for my delphi android app. i never had such error in any other app that i used – zeus Jul 23 '18 at 10:40
  • @DaveNottage: hmmm very interesting, if it this that seam that is a bug in the TnetHttpClient, but i need to investigate. not sure it's this need to investigate – zeus Jul 23 '18 at 10:43
  • @DaveNottage: not sure it's close, and even it's not very good to close the connection that is keep alive. i m framework i use (and reuse) always the same nethttpclient – zeus Jul 23 '18 at 10:46

0 Answers0