java.net.SocketException:断开的管道 [英] java.net.SocketException: Broken pipe
问题描述
java.net.SocketException
$ c $ c>
MESSAGE:损坏的管道
STACKTRACE:
java.net.SocketException:在java.net.SocketOutputStream.socketWrite0(Native方法)上
的断管
。 SocketOutputStream.socketWrite(SocketOutputStream.java:92)
在java.net.SocketOutputStream.write(SocketOutputStream.java:136)
在java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637)
....
重新启动tomcat服务后,它可以正常工作。 (我使用hibernate连接到mysql数据库)
我得到这个错误或我的JSP (...)
我会推测一下,但如果每天早上都会发生这种情况(即在一夜之后),那么它可能与MySQL在默认情况下8小时后关闭空闲连接的事实有关( wait_timeout
)。
如果是这种情况,请执行以下任一操作: configure tomcat在数据源配置中使用 增加MySQL的 I get this error or my jsp page every day:
validationQuery
测试借用连接:
<参数>
< name> validationQuery< / name>
<值>选择1< /值>
< / parameter>
wait_timeout
code> my.cnf / my.ini ,或者通过连接命令行SQL客户端并输入 SET GLOBAL wait_timeout = 86400
,或其他合适的秒数。java.net.SocketException
MESSAGE: Broken pipe
STACKTRACE:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637)
....
After restarting the tomcat service it works fine. (I use hibernate to connect to the mysql database)
I get this error or my JSP page every day (...)
I'm going to speculate a bit but if this happens every morning (i.e. after a night of inactivity), then it might be related to the fact that MySQL closes idle connections after 8 hours by default (the wait_timeout
).
If this is the case, either:
configure tomcat to test connections on borrow using a
validationQuery
in the datasource configuration:<parameter> <name>validationQuery</name> <value>select 1</value> </parameter>
increase MySQL's
wait_timeout
viamy.cnf/my.ini
, or by connecting with a command-line SQL client and enteringSET GLOBAL wait_timeout=86400
, or some other suitable number of seconds.
I'm not aware of all the consequences of the second option and don't really recommend it, at least not without getting more feedback from MySQL experts.
这篇关于java.net.SocketException:断开的管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!