Android: what is the reason for java.net.socketexception: the connection timed out?

Download and load data in my application. Everything is fine, but some of it gives strange responses and throws socketexception: connectiontimeout?

Would anyone please tell me the reasons for these exceptions? So I can find the problem?

Give me some solutions to avoid this exception

The log here

**

04-19 15:44:52.591: WARN/System.err(18199): java.net.socketException: Connection timed out
04-19 15:44:52.591: WARN/Smack/Packet(209): notify conn break (IOEx), close connection
04-19 15:44:52.591: DEBUG/Smack(209): [XMPPConn] close connection, notifyClosed=false
04-19 15:44:52.591: WARN/System.err(18199):     at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
04-19 15:44:52.591: WARN/System.err(18199):     at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
04-19 15:44:52.591: WARN/System.err(18199):     at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:458)
04-19 15:44:52.591: WARN/System.err(18199):     at org.apache.harmony.luni.net.socketInputStream.read(SocketInputStream.java:85)
04-19 15:44:52.591: WARN/System.err(18199):     at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
04-19 15:44:52.591: WARN/System.err(18199):     at org.apache.harmony.luni.internal.net.www.protocol.http.FixedLengthInputStream.read(FixedLengthInputStream.java:44)
04-19 15:44:52.591: WARN/System.err(18199):     at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
04-19 15:44:52.591: WARN/System.err(18199):     at java.io.FilterInputStream.read(FilterInputStream.java:133)
04-19 15:44:52.591: WARN/System.err(18199):     at com.logictreeit.pilot.utils.Download.Download1(Download.java:245)
04-19 15:44:52.591: WARN/System.err(18199):     at com.logictreeit.pilot.utils.Download.access$4(Download.java:225)
04-19 15:44:52.591: WARN/System.err(18199):     at com.logictreeit.pilot.utils.Download$DownloadTask.doInBackground(Download.java:171)
04-19 15:44:52.591: WARN/System.err(18199):     at com.logictreeit.pilot.utils.Download$DownloadTask.doInBackground(Download.java:1)
04-19 15:44:52.591: WARN/System.err(18199):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-19 15:44:52.591: WARN/System.err(18199):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-19 15:44:52.591: WARN/System.err(18199):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-19 15:44:52.591: WARN/System.err(18199):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-19 15:44:52.591: WARN/System.err(18199):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-19 15:44:52.591: WARN/System.err(18199):     at java.lang.Thread.run(Thread.java:1019)

**

Greetings, Srinivas

resolvent:

"Connection timeout" is the expected behavior in the network environment. In the mobile environment, it is even more expected that the network connection is unreliable. This means that the server cannot respond for a certain number of seconds

Because this is normal behavior, you need to handle it in the Android application. Try retry, display an error message to the user, or perform other appropriate actions

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>