我有一個程序,使用稱爲OpenCalais的Web服務,使用它的REST API。代碼正在工作,它只是有時Eclipse在控制檯上拋出一個異常,當我運行程序時。我該如何?解決這個下面是堆棧跟蹤:如何解決SocketTimeoutException
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:641)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:589)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1319)
at mx.bigdata.jcalais.rest.CalaisRestClient.post(CalaisRestClient.java:148)
at mx.bigdata.jcalais.rest.CalaisRestClient.analyze(CalaisRestClient.java:117)
at mx.bigdata.jcalais.rest.CalaisRestClient.analyze(CalaisRestClient.java:104)
at entity.UserClientAnalyseData.analyseData(UserClientAnalyseData.java:37)
at servlet.UserClientServlet.doPost(UserClientServlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
您的超時時間爲低或1-5秒。或者你打電話給的數據是減慢你的時間。 – Lyrion
這是否意味着我不能做太多的工作?因爲我不知道設置讀取超時值的文件在哪裏,我所做的只是導入JAR文件來運行程序。 –
您的讀取超時在正在從ws讀取數據的系統上設置。也許你正在問很多數據並需要分解它?而不是在一次呼叫中做2次呼叫? – Lyrion