我正在尝试从 VPC 中的 AWS Lambda 连接到我的 SQL Server RDS 实例(使用 .net core).
I am trying to connect to my SQL Server RDS instance from AWS Lambda in my VPC (using .net core).
当我尝试运行 Lambda 函数时,它返回:
When I attempt to run the Lambda function, it returns:
"errorType": "SqlException", "errorMessage": "Connection Timeout Expired.在登录后阶段超时时间已过.连接可能在等待服务器完成登录过程并响应时超时;或者它可能在尝试创建多个活动连接时超时.尝试连接到此服务器所花费的持续时间是 - [登录前]初始化=781;握手=1957;[登录]初始化=40;身份验证=122;[登录后] complete=12219;",
"errorType": "SqlException", "errorMessage": "Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=781; handshake=1957; [Login] initialization=40; authentication=122; [Post-Login] complete=12219;",
我已经配置了以下内容:
I have configured the following:
连接字符串看起来像这样(使用 Dapper 作为我的 ORM)
The connection string looks like this (using Dapper as my ORM)
string dbconnstr = @"server=vpc100-db.xyz.us-west-1.rds.amazonaws.com;database=dbMyDb;user id=sa;password=mypwd;";
知道我错过了什么吗?
已解决.数据库引擎版本是问题.
Solved. DB engine version was the issue.
事实证明,这不是 Lambda 或 VPC 和 RDS 的权限问题.无法从 Lambda(通过 c# .net core)连接到 RDS 是数据库版本!我正在连接到一个 RDS MS SQL 2008 R2,它使用本地代码而不是 Lambda.当我将 RDS 目标数据库更改为 MS SQL 2016 时,它起作用了!
It turns out it wasn't a permission problem with Lambda or the VPC and RDS. The inability to connect from Lambda (via c# .net core) to the RDS was the database version! I was connecting to a RDS MS SQL 2008 R2 which worked from local code but not from Lambda. When I changed the RDS target db to MS SQL 2016 it worked!
这篇关于AWS Lambda - 无法连接到 VPC 中的 SQL Server RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!