我也尝试将在Abp.io版本6(MVC应用程序)中编写的应用程序部署到AWS上的AWS ElasticBeanstalk + Postgresql示例。
如果我从本地env运行应用程序,db指向AWS示例,它就可以工作。
当我展开它的时候
Failed to connect to 172.31.2.40:5432
Mar 17 20:52:14 ip-172-31-21-214 web: ---> System.TimeoutException: Timeout during connection attempt
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|193_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.ConnectorPool.<Get>g__RentAsync|27_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: --- End of inner exception stack trace ---
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
Mar 17 20:52:14 ip-172-31-21-214 web: System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
Mar 17 20:52:14 ip-172-31-21-214 web: ---> Npgsql.NpgsqlException (0x80004005): Failed to connect to 172.31.2.40:5432
Mar 17 20:52:14 ip-172-31-21-214 web: ---> System.TimeoutException: Timeout during connection attempt
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Mar 17 20:52:14 ip-172-31-21-214 web: at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|193_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, Cancellat
我必须允许Web应用程序的IP符合AWS的规则吗?我应该使用相同的内部网络吗?
谢谢
1条答案
按热度按时间6jygbczu1#
这就是问题
Failed to connect to 172.31.2.40:5432
答案是肯定的。您应该使用相同的内部网络来访问数据库。