java.net.SocketTimeoutException: Read timed out问题排查

版权声明: https://blog.csdn.net/Soul_Programmer_Swh/article/details/80913843
问题日志:
java.sql.SQLException: I/O Error: Read timed out
	at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1053) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:465) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1304) ~[jtds-1.2.5.jar:1.2.5]
	at net.sf.log4jdbc.sql.jdbcapi.StatementSpy.executeQuery(StatementSpy.java:731) ~[log4jdbc-log4j2-jdbc4-1.16.jar:na]
	at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73) [c3p0-0.9.1.2.jar:0.9.1.2]
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:374) [c3p0-0.9.1.2.jar:0.9.1.2]
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishIdleResource(C3P0PooledConnectionPool.java:310) [c3p0-0.9.1.2.jar:0.9.1.2]
	at com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1999) [c3p0-0.9.1.2.jar:0.9.1.2]
	at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) [c3p0-0.9.1.2.jar:0.9.1.2]
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.6.0_43]
	at java.net.SocketInputStream.read(SocketInputStream.java:129) ~[na:1.6.0_43]
	at java.io.DataInputStream.readFully(DataInputStream.java:178) ~[na:1.6.0_43]
	at java.io.DataInputStream.readFully(DataInputStream.java:152) ~[na:1.6.0_43]
	at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:846) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:727) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.ResponseStream.peek(ResponseStream.java:88) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3932) ~[jtds-1.2.5.jar:1.2.5]
	at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1046) ~[jtds-1.2.5.jar:1.2.5]
	... 8 common frames omitted
2018-07-04 01:07:43 [ERROR] [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] jdbc.sqltiming - 221. Connection.getAutoCommit()

一般来说是数据库连接问题,没有连上或是网络问题(网络波动)。

查看服务器jdbc日志,发现报read timed out异常不是连续的,是间断的,查一段时间库断了,在查一段时间库又断了。。。。。

阅读更多

扫码向博主提问

soul_programmer_swh

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • Java
  • Spring
  • Database
  • 编程思想
去开通我的Chat快问
换一批

超时了,java.net.SocketTimeoutException: Read timed out

08-14

通过webservices访问数据库,查询数据时由于数据量比较大,基本90秒左右返回数据,但weblogic在执行后一分钟左右就报超时了:rn exception, unwinding nowrnorg.apache.cxf.interceptor.Fault: Could not send Message.rn at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSendernrInterceptor.java:64)rn at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)rn at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)rnrn at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)rnCaused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://localhost:8081/Service: Read timed outrn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2058)rn at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2043)rn at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)rn at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:639)rn at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSendernrInterceptor.java:62)rn at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)rn at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)rn at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)rn ... 34 morernCaused by: java.net.SocketTimeoutException: Read timed outrn at java.net.SocketInputStream.socketRead0(Native Method)rn at java.net.SocketInputStream.read(SocketInputStream.java:129)rn at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)rn at java.io.BufferedInputStream.read(BufferedInputStream.java:237)rn at weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:220)rn at weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:143)rn at weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:462)rn at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:364)rn at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:37)rn at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:952)rn at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2165)rn at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2134)rn at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1988)rn ... 43 morern查了很多资料依然没有解决,是需要在weblogic控制台设置呢,还是改如何处理?

求助!java.net.SocketTimeoutException: Read timed out

10-20

本地项目调用webservice服务时遭遇异常,控制台输出:rn信息: Interceptor has thrown exception, unwinding nowrnorg.apache.cxf.interceptor.Fault: Could not send Message.rn at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)rn at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:471)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:301)rn at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:253)rnrn at java.lang.Thread.run(Thread.java:619)rnCaused by: java.net.SocketTimeoutException: Read timed outrn at java.net.SocketInputStream.socketRead0(Native Method)rn at java.net.SocketInputStream.read(SocketInputStream.java:129)rn at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)rn at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)rn at java.io.BufferedInputStream.read(BufferedInputStream.java:317)rnrnjavax.xml.ws.soap.SOAPFaultException: Could not send Message.rn at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:141)rn at $Proxy73.appb(Unknown Source)rn at com.xxxxx.impl.sdaf.sssdd(fds.java:570)rn at com.xxxxx.impl.appla.appb(appa.java:76)rn at com.xxxxx.impl.appa$$FastClassByCGLIB$$d209058b.invoke()rn at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)rn at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)rn at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)rn at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)rnrnCaused by: java.net.SocketTimeoutException: Read timed outrn at java.net.SocketInputStream.socketRead0(Native Method)rn at java.net.SocketInputStream.read(SocketInputStream.java:129)rn at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)rn at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)rn rn ... 107 more。rn恳请大家帮忙分析解决下,谢谢!

请教 java.net.SocketTimeoutException: Read timed out

04-29

上传文件代码beanrn/**rn * @author lichuxiongrn */rnpackage arch.upload;rnrnimport java.io.*;rnimport java.util.Date;rnimport javax.servlet.http.*;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport javax.servlet.http.HttpSession;rnimport javax.servlet.ServletInputStream;rnrnrn public class UpFileThread implements Runnablern rn HttpServletRequest request;rn HttpServletResponse response;rn private boolean state;//线程是否已经启动rn private boolean running;//是否正在运行rn private boolean complete;//是否已经完成rn private int percent; rn rn public UpFileThread() rn super();rn state=false;rn running=false;rn complete=false;rn percent=0;rn rn rn /**rn * 初始化时把页面的request和response传递进来rn * @param requestrn * @param responsern */rn public UpFileThread(HttpServletRequest request,HttpServletResponse response) rn super();rn this.request=request;rn this.response=response;rn state=false;rn running=false;rn complete=false;rn percent=0;rn rn rn public void setRequest(HttpServletRequest request) rn this.request = request;rn rn public void setResponse(HttpServletResponse response) rn this.response = response;rn rn public synchronized boolean isComplete() rn return complete;rn rn public synchronized void setComplete(boolean complete) rn this.complete = complete;rn rn public synchronized int getPercent() rn return percent;rn rn public synchronized void setPercent(int percent) rn this.percent = percent;rn rn public synchronized boolean isRunning() rn return running;rn rn public synchronized void setRunning(boolean running) rn this.running = running;rn this.setState(running);rn rn public synchronized boolean isState() rn return state;rn rn public synchronized void setState(boolean state) rn this.state = state;rn rn /**rn * 判断能不能上传 后缀名,文件大小rn * @param suffixrn * @param sizern * @returnrn */rn public boolean canUpload(String suffix,int size)rn //System.out.println(suffix.toLowerCase());rn //System.out.println(size);rn Suffix suf=new SearchSuffix().getSuffixMember(suffix.toLowerCase());rn if(suf!=null&&suf.getSize().intValue()>=size)rn return true;rn rn return false;rn rn /**rn * 文件上传主要方法rn * @throws ServletExceptionrn * @throws IOExceptionrn */rn public synchronized void up() throws ServletException, IOExceptionrn String readLine;rn byte buf[]=new byte[512];rn rn ServletInputStream sis=request.getInputStream();rn rn int upFileSize=request.getContentLength();rn //开始读取rn int readLength=sis.readLine(buf,0,512);//去掉分隔行rn String boundary=new String(buf,0,readLength);rnrn int boundaryLength=boundary.length();//因为下面字节读取时会把回车换行符也读入rn rn readLength=sis.readLine(buf,0,512);rn readLine=new String(buf,0,readLength);rnrn int index=readLine.indexOf("filename=");//查找文件名rn String name=readLine.substring(index+10);rn name=name.substring(0, name.length()-3);//去掉末尾的分号,获得完整的文件名(注意中文名的显示)rn System.out.println(name);rn //查找文件后缀rn String suffix=name.substring(name.lastIndexOf(File.separator));rn suffix=suffix.substring(suffix.indexOf("."));rn rn //判断相应文件能不能传(后缀,大小)rn if(!canUpload(suffix, upFileSize))rn return ;rn rn //保存文件大小到session,供页面调用rn //request.getSession().setAttribute("upFileSize", new Integer(upFileSize));rn //设定新文件名rn String newName=Long.toString((new Date()).getTime());rn newName=newName+suffix;rn rn //设定文件 输出流rn String path=request.getRealPath("/")+"upfiles/";rn FileOutputStream out=new FileOutputStream(path+newName);rn int upedSize=0;rn //request.getSession().setAttribute("upedSize", new Integer(upedSize));rn tryrn //寻找文件起点rn while ( (readLength = sis.readLine(buf, 0, buf.length)) != -1) rn String s = new String(buf, 0, readLength);rn if ( (index = s.indexOf("Content-Type:")) != -1) rn break;rn rn //whilern sis.readLine(buf, 0, buf.length);//去掉一空行rn //读文件数据rn while((readLength = sis.readLine(buf, 0, buf.length)) != -1)rn upedSize+=readLength;rn this.setPercent((int)((upedSize/upFileSize)*100));//设置完成的百分数rn if ( (buf[0] == 45) && (buf[1] == 45) && (buf[2] == 45) && (buf[3] == 45) && (buf[4] == 45)) //若读结束rn break;rn rn out.write(buf,0,readLength);rn //out.flush();rn rn this.setPercent(100); //设置完成100rn this.setComplete(true); //设置完成标志rn catch(Exception e)rn e.printStackTrace();rn File tmp=new File(path+newName);rn tmp.delete();rn finallyrn out.close();rn sis.close();rn this.setRunning(false); //设置线程已经停止rn rn rn public void run()rn tryrn setRunning(true); //启动线程rn setComplete(false); //还没完成rn setPercent(0); //完成的了0%rn up(); //进入工作状态,上传rn catch(Exception e)rn e.printStackTrace();rn rn rnrnrnrnrn网页调用处代码rn<%@ page contentType="text/html; charset=gb2312" language="java" errorPage=""%>rnrnrn rn 文件上传rnrnrn<%session.removeAttribute("upFileBean"); %>rnrn<%rnupFileBean.setRequest(request);rnupFileBean.setResponse(response);rnnew Thread(upFileBean).start(); rn%>rnrnrnrnrn重启tomcat后第一次不管传什么文件都能正确上传rn但接下来传就出现如题的问题rn请高手指点一二。谢谢

憋了很久的问题-java.net.SocketTimeoutException: Read timed out

12-13

憋了很久的问题-java.net.SocketTimeoutException: Read timed outrnrnrn【问题描述】请求一个webservice偶尔会返回异常,如下:rnjava.net.SocketTimeoutException: Read timed outrn at java.net.SocketInputStream.socketRead0(Native Method)rn at java.net.SocketInputStream.read(SocketInputStream.java:129)rn at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)rn at java.io.BufferedInputStream.read(BufferedInputStream.java:235)rn at weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:220)rn at weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:143)rn at weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:420)rn at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:345)rn at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:31)rn at com.lingtu.lbs.util.WebUtil.requestLBMP(WebUtil.java:735)rn at com.lingtu.lbs.gis.webgis.doPost(webgis.java:99)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rn at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)rn at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)rn at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)rn at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)rn at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3211)rn at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)rn at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)rn at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)rn at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)rn at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)rn at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)rn at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)rnrn这个异常并不是每次都抛出,而是当对方的webservice响应时间超过约2秒的时候才会抛出,我的程序并没有设置超时,而在家中的调试环境去访问这个webservice这种异常无法重现,已经排除了网络问题以及编码上的问题。所以我考虑是操作系统或weblogic设置不当(我方程序的weblogic容器,因为我们weblogic处理的http请求也很多)所引起,请大家帮我看看是什么原因?不胜感激!!!rnrn就是我在我们的weblogic中部署了一个war,这个war里面有一个类去请求另一个webservice,但是发现当对方返回响应的时候,有时我这边会抛出timeout异常,已经对网络进行抓包,发现我们产生异常的时候,对方的响应还没有发送完毕,我方主机就发送了断开连接的包。这个包我的程序肯定没有发,我怀疑是操作系统或者weblogic的原因。rnrn我用的是weblogic server9.2 有时请求和响应正常,有时请求响应不正常;请求不正常的时候抓包表现为:大约两秒左右,对方的响应还没有发送完毕,我方主机就发送了断开连接的包。rn

没有更多推荐了,返回首页