azure - 在 NestJS 中配置 TypeORM 以使用 Azure SQL

标签 azure azure-sql-database nestjs typeorm

我一直在使用本地 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/

相关文章:

azure - 如何在 Azure 免费服务中免费创建虚拟机

python - 如何在 Azure 数据工厂 - Databricks 中使用 continuation_token 获取 ADF Pipeline 运行详细信息的下一页?

sql - 在 SQL Server 上仅显示一个数据库

node.js - 存储 GeoJson 点并在给定距离/半径内查找点 | NODEJS、Postgres、NestJs、TypeOrm

node.js - 测试 NestJS 中是否触发了事件

angular - 使用 Nestjs/Angular 初始化 MongoDB 时出错

node.js - 使用 npm install aws-azure-login 命令安装时无法运行 aws-azure-login

azure - 在 VSTS 上的 Azure CLI 任务中设置输出变量

Azure SQL 100% DTU 使用率

c# - 数据未插入到 Azure 上托管的 SQL Server 数据库中