我正在尝试将一个连接到RDS上的Postgres数据库的netcoreapp2.0应用程序部署到AWS Lambda,但以下代码失败:
let testConn = "Host=hostNameHere;Username=userNameHere;Password=passwordHere;Database=postgres";
let conn = new NpgsqlConnection(testConn)
try
printfn "Trying to open a connection"
conn.Open()
with ex ->
printfn "Exception trying to open conn:\n%O" ex
我得到了以下堆栈跟踪:
System.TimeoutException: The operation has timed out.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.<RawOpen>d__153.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnector.<Open>d__149.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.ConnectorPool.<AllocateLong>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnection.Open()
at Masse.Common.SQL.query[T](String connectString, SqlQuery q) in /home/nat/Projects/shopmasse-backend/fsharp/src/Masse.Common/Sql.fs:line 40
有人知道为什么这个在我的机器上本地运行正常,但部署到AWS Lambda后失败了吗?
以下是一些GitHub问题,可能提供了额外的上下文:
一些额外的细节: - 数据库引擎: PostgreSQL 9.6.6 - Npgsql 版本: 4.0 - .NET 版本: netcoreapp2.0
如果需要提供任何其他信息,请告诉我。谢谢!