gpt4 book ai didi

asp.net - 来自IIS ASP.NET容器的SQL连接问题

转载 作者:行者123 更新时间:2023-12-02 18:34:42 24 4
gpt4 key购买 nike

背景:
我正在使用最新的4.8 ASP net容器将应用程序移植到docker容器。它们都使用SQL Server连接。

App1:框架4.8,完全没有问题。
App2:框架4.6.2,根本无法建立与SQL Server的连接。

这是连接字符串:
<add name="DefaultConnection" connectionString="Data Source=172.31.0.2; Initial Catalog=Integ_Catalog; User ID=MYUSER; Password=Pa55W0rd; MultipleActiveResultSets=True;Connect Timeout=120" providerName="System.Data.SqlClient" />
从容器内部,我运行了Powershell来验证连接字符串是否100%有效。我已经将dapper更新为最新版本,希望对您有所帮助。有什么想法可以尝试吗?

跟踪

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()

*更新*

当应用程序与数据库位于同一AWS VPC中时,调用将失败。但是,当它们位于不同的VPC中时,它将起作用。这没有任何意义,您会以为相反。在数据库,应用程序/主机上以及在VPC上的联网都很好。

最佳答案

解决方案是将应用程序移至外部VPC,为什么?世界可能永远不会知道:)

关于asp.net - 来自IIS ASP.NET容器的SQL连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61668487/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com