连接到nodejs中的heroku postgress数据库时出错

编程入门 行业动态 更新时间:2024-10-20 07:40:49
本文介绍了连接到nodejs中的heroku postgress数据库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用pg 7.4.2 npm软件包。

我的数据库升级到10.2后似乎无法连接。

要清楚的是,我已经连续6个月没有问题地使用相同的连接字符串,该连接字符串具有?ssl = true附加到它。

$ b $

AssertionError [ERR_ASSERTION]:false == true 位于Object.exports.connect(_tls_wrap.js:1099:3)位于Socket。< anonymous> (/home/e/express/testpg/node_modules/pg/lib/connection.js:94:23)在Object.onceWrapper(events.js:219:13)在Socket.emit( at Socket.emit(domain.js:421:20) at addChunk(_stream_readable.js:269:12) at readableAddChunk(_stream_readable.js :256:11) at Socket.Readable.push(_stream_readable.js:213:10) at TCP.onread(net.js:598:20) $ b $ <$ p b

我尝试在连接字符串的末尾添加/删除?ssl = true,并在构造函数中添加/删除ssl:true。我也尝试过和没有承诺。同样的错误,无论本地和部署到heroku上。

进口:

import {Pool,Client} from'pg'

方法1:

let pool = new Pool({ connectionString:csnew, ssl:true }) pool.connect()。then(client => { console.log('connected')}) .catch(e => { console.log(e)})

方法2:

let pgclient = new Client({ connectionString:csnew, ssl:true )) pgclient.connect()。then(()=> { console.log('connected')})。catch(e => { console.log (e)})

解决方案

v7.4.2打破了对SSL的支持。 这是未解决的问题。

您必须严格使用v7.4.1才能解决问题。

更新

7.4.3版解决了问题。

It seems after my database was upgraded to 10.2 I'm unable to connect.

I'm using the pg 7.4.2 npm package.

To be clear, I have been connecting without issue for 6 months using the same connection string which had ?ssl=true appended to it.

I get this error connecting via Pool or Client.

AssertionError [ERR_ASSERTION]: false == true at Object.exports.connect (_tls_wrap.js:1099:3) at Socket.<anonymous> (/home/e/express/testpg/node_modules/pg/lib/connection.js:94:23) at Object.onceWrapper (events.js:219:13) at Socket.emit (events.js:127:13) at Socket.emit (domain.js:421:20) at addChunk (_stream_readable.js:269:12) at readableAddChunk (_stream_readable.js:256:11) at Socket.Readable.push (_stream_readable.js:213:10) at TCP.onread (net.js:598:20)

I'm now hardcoding the full postgres connection string so there is no issue with env variables.

I've tried adding/removing ?ssl=true to the end of the connection string and adding/removing ssl:true from the constructor. I've also tried with and without promises. Same error no matter what on both local and deployed to heroku.

imports:

import { Pool, Client } from 'pg'

method 1:

let pool = new Pool({ connectionString: csnew, ssl: true }) pool.connect().then( client => { console.log('connected') }) .catch(e=> { console.log(e) })

method 2:

let pgclient = new Client({ connectionString: csnew, ssl: true }) pgclient.connect().then( () => { console.log('connected') }).catch(e=> { console.log(e) })

解决方案

That's because v7.4.2 broke its SSL support. Here's the open issue.

You need to use strictly v7.4.1 till the issue is resolved.

UPDATE

Version 7.4.3 fixed the issue.

更多推荐

连接到nodejs中的heroku postgress数据库时出错

本文发布于:2023-10-24 14:29:20,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   数据库   heroku   nodejs   postgress

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!