2011-04-19 91 views
4

在我的應用程序中下載加載數據。每一件事情都很好,但有一些事情給出了很奇怪的反應,並拋出了socketException:connectiontimout?Android:java.net.SocketException的原因是什麼:連接超時?

請任何人告訴我這些異常的原因是什麼?所以我可以找出問題?

給我一些解決方案,以避免這些類型的異常

這裏記錄的那張............

**

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) 

**

Regards, Srinivas

回答

3

「連接超時」是網絡環境中的預期行爲。在網絡連接可能不可靠的移動環境中,這一點甚至更令人期待。這意味着服務器無法響應一定的秒數。

因爲這是正常的行爲,你需要在你的android應用程序中處理它。嘗試重試,向用戶顯示錯誤消息,或者執行其他適當的操作。

相關問題