Telma Cruz Telma Cruz - 2 months ago 20
MySQL Question

Broken Pipe Exception on Grails App

I developed an application on Grails 2.4.4 using jdk 1.7 and MySQL Workbench 6.3. It works for some time, but after some hours of the deployment i try to log in, it stops working and throws the exception " 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: Broken pipe
at com.mysql.jdbc.MysqlIO.send(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
at com.mysql.jdbc.PreparedStatement.executeInternal(
at com.mysql.jdbc.PreparedStatement.executeQuery(
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(
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

I have an external file with the following configurations:

dataSource(BasicDataSource) {
url = "jdbc:mysql://"
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

I also added
file and
mysqld : ALL : ACCEPT
file on

Most of the properties were added after some research in another threads but it still doesnt work.
Can anyone help me find a solution to solve this issue?


After trying the solution given by Dipak Thoke it still throws the broken pipe exception. It also shows the following error

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.

Should i change the "wait_timeout" value? Cause i already have the "autoReconnect=true" property


With the solutions that were presented here my application was always getting a broken pipe exception. I created a webservice with a script the runs every hour, that way the application never loses its connection to the database. Since then the exception was never been thrown again. Thank you all for your answers anyway :)