SocketTimeoutException:读取超时

时间:2011-08-11 08:39:04

标签: java jsp tomcat jsoup

我有一个使用以下命令读取HTML页面的Web应用程序

Document doc = Jsoup.connect(url).post();

然后我的Web应用程序将通过一些修改再次重新显示HTML页面 它工作正常,它读取我给它的任何HTML页面。但是,我的程序没有接受某些页面。所以应用程序给了我以下错误 类型异常报告

消息

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: java.net.SocketTimeoutException: Read timed out
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:404)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.net.SocketTimeoutException: Read timed out
    java.net.SocketInputStream.socketRead0(Native Method)
    java.net.SocketInputStream.read(SocketInputStream.java:129)
    java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
    sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
    java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
    org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:381)
    org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:364)
    org.jsoup.helper.HttpConnection.execute(HttpConnection.java:143)
    org.jsoup.helper.HttpConnection.post(HttpConnection.java:138)
    org.apache.jsp.ModelsForAllE_jsp._jspService(ModelsForAllE_jsp.java:105)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

为什么它适用于某些页面并且有些页面会给我这个错误? 我的应用程序或Tomcat是一个问题吗?

感谢,

1 个答案:

答案 0 :(得分:0)

它可能只是一个缓慢的网站 - 所以你需要增加任何超时。

或者也许是为了防止拒绝服务攻击 您根据请求发送了哪些标题?您需要确保您的请求标头看起来尽可能接近真实的浏览器请求。例如。您需要发送您的浏览器类型,您接受的返回类型等等。