1

I have a program that uses a web service called OpenCalais,using it's REST API.The codes are working,it is just that sometimes Eclipse throws an exception on the console when I run the program.How do I resolve this?Below is the stacktrace:

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)
Marcus Dryice Koh
  • 117
  • 1
  • 2
  • 13
  • 1
    Your timeout is either to low, 1-5sec. Or the ws you are calling data from is to slow hitting your time out. – Lyrion Nov 05 '12 at 07:39
  • 1
    Does that mean I cannot do much about it?Because I do not know where are the files that set the read timeout value,what I did is only import the JAR files to run the program. – Marcus Dryice Koh Nov 05 '12 at 07:45
  • 1
    Your read timeout is set on the system that is reading data from the ws. Maybe you are asking way to much data and need to split it up? Instead of doing it in 1 call do it in 2 calls? – Lyrion Nov 05 '12 at 07:54
  • 1
    I don't think it is possible,as my code needs the data to be retrieved at once,I guess I need to catch the exception and continue program execution. – Marcus Dryice Koh Nov 05 '12 at 09:15

1 Answers1

1

Either speed up the server, or resolve whatever is slowing it down, or raise your read timeout to a more realistic value.

user207421
  • 305,947
  • 44
  • 307
  • 483