【发布时间】:2021-05-11 00:30:02
【问题描述】:
我有一个在 Heroku 上运行的 NodeJS 应用程序,带有 Heroku Postgres 数据库。
现在(pg@^7.18.2 & knex@^0.21.14),当我运行 heroku run knex migrate:latest -a my-awesome-app 时,我收到以下错误:
KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
at Client_PG.acquireConnection (/app/node_modules/knex/lib/client.js:348:26)
at async listCompleted (/app/node_modules/knex/lib/migrate/migration-list-resolver.js:12:3)
at async Promise.all (index 1)
at async Migrator.latest (/app/node_modules/knex/lib/migrate/Migrator.js:64:29)
at async Command.<anonymous> (/app/node_modules/knex/bin/cli.js:172:32)
我在 Google 上搜索,发现很多人说解决方案是更新到 pg@^8,所以我这样做了(将 pg 和 knex 都升级到了他们最新的稳定版本)但我现在遇到了另一个错误。这次的错误是:
heroku run knex migrate Error: self signed certificate
所以我用谷歌搜索了新的错误,人们说解决方案是将ssl: { rejectUnauthorized: false }, 添加到 Knex 配置对象,但我也这样做了,但我仍然收到“自签名证书”错误。
我什至尝试了suggestions here,但仍然没有运气,错误仍然存在。
一些答案建议我应该回到版本 pg@^7 来克服证书错误,但就我而言,我只是回到超时获取连接错误。
我被困在两个错误之间,似乎没有任何效果。
【问题讨论】:
-
你有用于连接的 cert/key/ca 吗?
-
不,我需要一个吗?如果是,我该如何获得。
-
不确定heroku .. 可能不能according to this。虽然你配置什么来从你的 heroku 应用程序连接? (不使用
knexcli) -
你能分享你的knexfile吗?我想知道您是否将
ssl块放在了错误的位置,或者是否还有其他特定于 Heroku 的事情发生。
标签: node.js postgresql heroku knex.js