无法通过VPN从DotNet Core连接到SQL

问题描述 投票:1回答:1

我已经尝试解决这个问题好几天了,所以我在这里尝试看看是否还有其他想法可以尝试。

我可以很好地连接到本地SQL Express,但是当尝试使用单独的VPN连接到位于两个不同公司的SQL时,无法从.NET Core / VS Code / dotnet.exe访问。

我在老板提供的新笔记本电脑上遇到此问题。

到目前为止我为解决这个问题所做的尝试:

  • 检查ConnectionString一千次
  • 从具有相同应用程序的我的个人固定计算机]中试过,并连接到VPN,工作正常
  • 从Microsoft SQL Server Management Studio连接,工作正常
  • ,使用与ConnectionString中相同的SQL帐户
  • 使用PortQueryUI.exe检查的服务器端口:UDP端口1434是LISTENING
  • ,TCP端口1433(ms-sql-s服务):LISTENING
  • 在ConnectionString中使用IP尝试,前缀为“ tcp:
  • ”和/或后缀为“ ,1433
  • 降级为使用2.1.1
  • 的.NET Core SDK(与固定计算机相同,低于2.1.16,相同错误
  • 在Windows防火墙中打开的传出和传入TCP 1433和UDP 1434
  • 将VSCode和dotnet.exe添加到Windows防火墙中允许的应用程序中
  • 无线网络和VPN连接都设置为“私人”
  • Ran VSCode以管理员身份(不是)”>
  • 尝试安装的用户版本和计算机版本
  • 已验证appSettings.json中的ConnectionString在运行代码时实际使用(调试时检查)
  • ConnectionString格式:

"DefaultConnection": "Server=<IPToServer>;Database=<DBName>;User ID=<UserName>;Pwd=<Password>"

都不是命名实例,一个是SQL Express,一个是SQL Server。

没有tcp:

的错误:
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 (1326): The user name or password is incorrect

但是用户名和密码不正确。当也切换到名称管道时,我也从MSSMS收到该消息,但是当更改为TCP时,我可以连接(从MSSMS)。

tcp:

的错误:
An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call.

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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

任何人有什么想法可以尝试吗?由于它可以在我的另一台计算机上工作,因此我可以肯定是笔记本电脑上的某种原因导致了它。

我已经尝试解决这个问题好几天了,所以我在这里尝试看看是否还有其他想法可以尝试。我可以很好地连接到本地SQL Express,但是尝试连接到位于...

c# sql-server .net-core entity-framework-core windows-firewall
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.