Grails App 上的破管异常
Broken Pipe Exception on Grails App
我使用 jdk 1.7 和 MySQL Workbench 6.3 在 Grails 2.4.4 上开发了一个应用程序。它工作了一段时间,但在部署几个小时后我尝试登录,它停止工作并抛出异常 "java.net.SocketException: Broken pipe".
2016-10-24 09:40:53,599 [http-nio-8080-exec-12] ERROR errors.GrailsExceptionResolver - SocketException occurred when processing request: [POST] /login/autenticacao
Broken pipe. Stacktrace follows:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3832)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
at org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2.doCall(GormStaticApi.groovy:102)
at sig.PasswordEncrypt.verificaAutenticacao(PasswordEncrypt.groovy:25)
at sig.LoginController$_closure1.doCall(LoginController.groovy:20)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我有一个具有以下配置的外部文件:
beans{
dataSource(BasicDataSource) {
url = "jdbc:mysql://127.0.0.1/db_name?autoReconnect=true"
username = "root"
password = "root"
pooled = true
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
maxAge = 10 * 60000
jdbcInterceptors = "ConnectionState"
validationInterval = 15000
minIdle = 5
maxIdle = 25
maxWaitMillis = 0
timeBetweenEvictionRunsMillis = 1000 * 60 * 30
numTestsPerEvictionRun = 3
minEvictableIdleTimeMillis = 1000 * 60 * 30
validationQuery = "SELECT 1"
validationQueryTimeout = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = true
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
我还将 port:3306
添加到 my.cnf
文件,将 mysqld : ALL : ACCEPT
添加到 /etc
文件夹中的 hosts.allow
文件。
大多数属性是在另一个线程中进行一些研究后添加的,但它仍然不起作用。
谁能帮我找到解决这个问题的方法?
编辑
在尝试了Dipak Thoke 给出的解决方案后,它仍然抛出broken pipe 异常。它还显示以下错误
2016-10-25 09:03:33,683 [http-nio-8080-exec-37] ERROR spi.SqlExceptionHelper - The last packet successfully received from the server was 38,766,997 milliseconds ago. The last packet sent successfully to the server was 38,766,997 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
我应该更改 "wait_timeout" 值吗?因为我已经有了 "autoReconnect=true" 属性
您需要 c3p0 您的项目
步数:1
添加这个"BuildConfig.groovy"
dependencies {
// specify dependencies here under either 'build', 'compile'
compile 'c3p0:c3p0:0.9.1.2'
}
第 2 步:
数据源groovy:
现在您的数据源将是这样的,只删除其他内容。
beans {
dataSource(BasicDataSource) {
**url = "jdbc:mysql://127.0.0.1/db_name"**
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
pooled = true
}
}
了解更多信息
Do I need to use C3P0 pooling library in my (grails) web application?
How do I configure c3p0 for a grails 2.X application with multiple datasources?.
http://blog.nutpan.com/2013/07/grails-broken-pipe-and-cannot-release.html
谢谢
使用此处介绍的解决方案,我的应用程序总是出现管道损坏异常。我用每小时运行一次的脚本创建了一个网络服务,这样应用程序就永远不会失去与数据库的连接。从那以后,再也没有抛出异常。无论如何,谢谢大家的回答:)
我使用 jdk 1.7 和 MySQL Workbench 6.3 在 Grails 2.4.4 上开发了一个应用程序。它工作了一段时间,但在部署几个小时后我尝试登录,它停止工作并抛出异常 "java.net.SocketException: Broken pipe".
2016-10-24 09:40:53,599 [http-nio-8080-exec-12] ERROR errors.GrailsExceptionResolver - SocketException occurred when processing request: [POST] /login/autenticacao
Broken pipe. Stacktrace follows:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3832)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
at org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2.doCall(GormStaticApi.groovy:102)
at sig.PasswordEncrypt.verificaAutenticacao(PasswordEncrypt.groovy:25)
at sig.LoginController$_closure1.doCall(LoginController.groovy:20)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我有一个具有以下配置的外部文件:
beans{
dataSource(BasicDataSource) {
url = "jdbc:mysql://127.0.0.1/db_name?autoReconnect=true"
username = "root"
password = "root"
pooled = true
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
maxAge = 10 * 60000
jdbcInterceptors = "ConnectionState"
validationInterval = 15000
minIdle = 5
maxIdle = 25
maxWaitMillis = 0
timeBetweenEvictionRunsMillis = 1000 * 60 * 30
numTestsPerEvictionRun = 3
minEvictableIdleTimeMillis = 1000 * 60 * 30
validationQuery = "SELECT 1"
validationQueryTimeout = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = true
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
我还将 port:3306
添加到 my.cnf
文件,将 mysqld : ALL : ACCEPT
添加到 /etc
文件夹中的 hosts.allow
文件。
大多数属性是在另一个线程中进行一些研究后添加的,但它仍然不起作用。 谁能帮我找到解决这个问题的方法?
编辑
在尝试了Dipak Thoke 给出的解决方案后,它仍然抛出broken pipe 异常。它还显示以下错误
2016-10-25 09:03:33,683 [http-nio-8080-exec-37] ERROR spi.SqlExceptionHelper - The last packet successfully received from the server was 38,766,997 milliseconds ago. The last packet sent successfully to the server was 38,766,997 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
我应该更改 "wait_timeout" 值吗?因为我已经有了 "autoReconnect=true" 属性
您需要 c3p0 您的项目
步数:1
添加这个"BuildConfig.groovy"
dependencies {
// specify dependencies here under either 'build', 'compile'
compile 'c3p0:c3p0:0.9.1.2'
}
第 2 步:
数据源groovy: 现在您的数据源将是这样的,只删除其他内容。
beans {
dataSource(BasicDataSource) {
**url = "jdbc:mysql://127.0.0.1/db_name"**
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
pooled = true
}
}
了解更多信息
Do I need to use C3P0 pooling library in my (grails) web application?
How do I configure c3p0 for a grails 2.X application with multiple datasources?.
http://blog.nutpan.com/2013/07/grails-broken-pipe-and-cannot-release.html
谢谢
使用此处介绍的解决方案,我的应用程序总是出现管道损坏异常。我用每小时运行一次的脚本创建了一个网络服务,这样应用程序就永远不会失去与数据库的连接。从那以后,再也没有抛出异常。无论如何,谢谢大家的回答:)