DB connection not available after period of inactivity (play 2.6)

556 views
Skip to first unread message

duh...@hillmart.in

unread,
Nov 20, 2017, 3:46:09 AM11/20/17
to Play Framework
I have been getting the following exceptions since I''ve started  my project.
When I start my app server and ran my services, there is not problem with db connections . But when there is no database activity for a period of time and try to run those services again, I always get db connection not available exception.
I've tried to change the default hikaricp configurations but its not working. Would really appreciate if someone help me.  (I'm not very good in english so please ingore if there are any mistakes)

Here is my applcation.conf

play.db {
# The combination of these two settings results in "db.default" as the
# default JDBC pool:
config = "db"
#default = "default"

# Play uses HikariCP as the default connection pool. You can override
# settings by changing the prototype:
prototype {
# Sets a fixed JDBC connection pool size of 50
hikaricp.minimumIdle = null
hikaricp.maximumPoolSize = 10
hikaricp.connectionTimeout = 30 seconds
hikaricp.idleTimeout = 10 minutes
hikaricp.maximumPoolSize = 10
hikaricp.autoCommit = true
# The max lifetime of a connection
hikaricp.maxLifetime = 30 minutes
}
}


db {
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`

# https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
#default.driver = org.h2.Driver
#default.url = "jdbc:h2:mem:play"
#default.username = sa
#default.password = ""

# You can turn on SQL logging for any datasource
# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
default.logSql=true
}
slick.dbs.default.profile="slick.jdbc.MySQLProfile$"
slick.dbs.default.db.driver="com.mysql.jdbc.Driver"
slick.dbs.default.db.url="db url "
slick.dbs.default.db.user="user"
slick.dbs.default.db.password="password"


play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[SQLTransientConnectionException: db - Connection is not available, request timed out after 1002ms.]]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:255)
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:182)
    at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:251)
    at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:250)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:412)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
    at play.api.libs.streams.Execution$trampoline$.executeScheduled(Execution.scala:109)
    at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:71)
    at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
Caused by: java.sql.SQLTransientConnectionException: db - Connection is not available, request timed out after 1002ms.
    at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:548)
    at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:186)
    at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:83)
    at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:18)
    at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:439)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:47)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:38)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:218)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:217)

leono...@lunatech.com

unread,
Mar 6, 2018, 5:11:24 PM3/6/18
to Play Framework
Hi! Did you ever managed to understand the issue you reported here?
Reply all
Reply to author
Forward
0 new messages