【问题标题】:Sails rejecting PostgreSQL connection with sails-postgresql moduleSails 拒绝 PostgreSQL 与sails-postgresql 模块的连接
【发布时间】:2016-10-02 00:17:06
【问题描述】:

我在 Intranet 环境中有一个 Sails Web 应用程序。平均约 12 个用户同时登录。最终,我收到来自sails-postgresql 的经典连接被拒绝消息,持续至少 3 分钟,拒绝向应用发出的所有 http 请求。

Error creating a connection to Postgresql using the following settings:
{ 
...
schema: true,
ssl: false,
adapter: 'sails-postgresql',
poolSize: 50
...
}

我要么得到{ [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'write' } 要么得到{ [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

我的 PostgreSQL 记录以下消息: 由于目标机器主动拒绝,无法建立连接。

如您所见,sails.config.connections 中的poolSize 设置为 50,postgresql.conf 中的max_connections 设置为 100。我没有将此数据库用于其他用途。

我的池大小设置是否正确?是 Sails 的问题还是 Postgres 的问题?

【问题讨论】:

  • 我猜,它在某处泄漏了连接,它会被参数poolIdleTimeout 自动纠正,但从长远来看并没有帮助。可能值得将其记录在 Sails 上。我不会为此责怪node-postgres 驱动程序,它在连接方面非常可靠。

标签: node.js postgresql sails.js connection-pooling sails-postgresql


【解决方案1】:

尝试在 postgres 配置文件 postgresql.conf 中增加 max_connections,在我的 Ubuntu 15.04 linux 中它位于以下路径:

/etc/postgresql/9.4/main/postgresql.conf

【讨论】:

  • 我将它设置为 max_connections = 100。我应该增加多少? Sails 连接中的池大小为 50。
猜你喜欢
  • 2018-01-29
  • 1970-01-01
  • 2015-09-24
  • 1970-01-01
  • 2017-08-05
  • 2017-02-17
  • 2015-06-21
  • 1970-01-01
  • 2012-06-05
相关资源
最近更新 更多