Heroku Postgres: This connection has been closed

后端 未结 2 1850
傲寒
傲寒 2021-01-18 06:05

I developed a small Heroku + Grails + Postreg application. It would work fine somewhat 20 minutes after deployment, after that I always get:

 This connection         


        
相关标签:
2条回答
  • 2021-01-18 06:17

    A combination of @Macchiatow's answer and @Jonik's comment, this is what I used to work, with fewer properties:

    dataSource {
        pooled = true
        properties {
            testOnBorrow = true
            testWhileIdle = true
            testOnReturn = true
            validationQuery = "SELECT 1"
        }
        driverClassName = "org.postgresql.Driver"
        dialect = "..."
    }
    
    0 讨论(0)
  • 2021-01-18 06:30

    I have resolved it myself by adding this to DataSource.groovy:

    dataSource {
        pooled = true
        properties {
           maxActive = -1
           minEvictableIdleTimeMillis=1800000
           timeBetweenEvictionRunsMillis=1800000
           numTestsPerEvictionRun=3
           testOnBorrow=true
           testWhileIdle=true
           testOnReturn=true
           validationQuery="SELECT 1"
        }
    }
    
    0 讨论(0)
提交回复
热议问题