java.net.SocketException MESSAGE: Broken pipe (Write failed)

5099 단어 Java 프레임워크
(1) 내 프로젝트 환경:javaweb 프로젝트는 c3p0 연결 탱크와 mysql 데이터베이스 통신을 사용하여centos7의tomcat 용기에서 실행됩니다.증상은 다음과 같다.간혹 다음과 같은 오류(대개 하루에 한 번, 시간은 정해지지 않음)를 보고하는데, 이번 데이터베이스 삽입은 실패하지만 다시 삽입하면 성공할 수 있습니다.2.내 c3p0 설정은 다음과 같다.

	
		root
		  
		com.mysql.jdbc.Driver
		jdbc:mysql:///    
	
 

3. 다음과 같이 오류 보고: ** BEGIN NESTED EXCEPTION **
java.net.SocketException MESSAGE: Broken pipe (Write failed)
STACKTRACE:
java.net.SocketException: Broken pipe (Write failed) at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) at java.net.SocketOutputStream.write(SocketOutputStream.java:155) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665) at com.mysql.jdbc.Connection.execSQL(Connection.java:3176) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:345) at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:287) at dao.RechargeMoneyDao.getOrderIdByDeviceNum(RechargeMoneyDao.java:44) at service.ShengKeService.getCheckInfo(ShengKeService.java:144) at web.FindOrderServlet.doGet(FindOrderServlet.java:57) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) at org.apache.coyote.AbstractProtocol A b s t r a c t C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 637 ) a t o r g . a p a c h e . t o m c a t . u t i l . n e t . J I o E n d p o i n t AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint AbstractConnectionHandler.process(AbstractProtocol.java:637)atorg.apache.tomcat.util.net.JIoEndpointSocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor W o r k e r . r u n ( T h r e a d P o o l E x e c u t o r . j a v a : 624 ) a t o r g . a p a c h e . t o m c a t . u t i l . t h r e a d s . T a s k T h r e a d Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread Worker.run(ThreadPoolExecutor.java:624)atorg.apache.tomcat.util.threads.TaskThreadWrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
** END NESTED EXCEPTION **
(2).솔루션
이른바 8시간 문제가 발생했기 때문에 c3p0의 기본 maxIdleTime이 0이면 연결이 영원히 연결을 버리지 않는다는 뜻이다.idleConnectionTestPeriod는 기본적으로 0으로 연결 탱크의 연결 유효성을 검사하지 않습니다.
그래서 설정을 다음과 같이 수정해야 합니다.

	
		  
		  
		com.mysql.jdbc.Driver
		jdbc:mysql:///    
        
		true
		
		C3P0TestTable
		
		18000
		
		25000
	
 

좋은 웹페이지 즐겨찾기