我一直在使用本地 mysql 配置,但当我尝试切换到 Azure SQL 连接时,我收到错误消息 - 错误 [TypeOrmModule] 无法连接到数据库。重试 (1)... 错误:在 TCP.onStreamRead 处读取 ECONNRESET (internal/stream_base_commons.js:201:27)
我创建了另一个应用程序,它使用 tedious 和 Node 来确保它不是与 Azure 相关的东西。
下面是我的配置设置 -
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { UserEntity } from '../user/user.entity';
export const typeOrmConfig: TypeOrmModuleOptions = {
type: 'mysql',
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
entities: [UserEntity],
extra: {
encrypt: true,
},
};
最佳答案
"ECONNRESET" indicates that the opposite side of the TCP discussion abruptly terminated the connection. This is most likely the result of one or more application protocol failures. You might check the API server logs to see if anything is being reported.
该错误(不是警告)表示连接已被对等方重置。远程对等方强制终止现有连接。强制关闭是突然的,因为它是意外的。
您的互联网连接可能会阻止您连接到某些服务器。
确定是否有任何事物干扰您的网络(设置),例如虚拟机、防火墙等。
关于azure - 在 NestJS 中配置 TypeORM 以使用 Azure SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69189856/