I have also faced same problem.It seems like application not getting connection from connection i have used configuration:

db.default.acquireRetryDelay=5 seconds 
db.default.acquireRetryDelay=5 seconds
db.default.idleMaxAge=10 minute 
db.default.idleConnectionTestPeriod=5 minutes 
db.default.initSQL="SELECT 1" 
db.default.maxConnectionAge=1 hour

then never get error(Timed out waiting for a free available connection).(my application deployed on heroku with postgres database)


The problem was in the implicit session definition in the BaseController trait. It seems that the session definition needs to be on the Action level and not on the controller level - unfortunately I can't explain the reason for that (yet).

trait BaseController extends Controller with Secured {
    //REMOVED this code
    //import play.api.Play.current
    //implicit def session: SessionDef = play.api.db.slick.DB.withSession {
    //    implicit session => {session}

Updated controller action using DbAction helped - not resulting in connection timeouts.

trait Application extends Controller {
  def index = DBAction { implicit request =>
    request.session.get("email") flatMap (email => UserService.findByEmail(email)) map { user =>
    } getOrElse {

object Application extends Controller with Application

So what is still missing is mixing an authenticated action with the DBAction of play-slick. The very same question has been asked here: compose slick dbaction with authenticated action

Maybe someone of the slick/play-slick team can step in and answer these questions?

Related Query

More Query from same tag