与服务器成功建立连接,但是在登录前握手期间发生错误。 TCP提供程序,错误:0 [英] A connection was successfully established with the server, but then an error occurred during the pre-login handshake. TCP provider, error: 0

查看:4763
本文介绍了与服务器成功建立连接,但是在登录前握手期间发生错误。 TCP提供程序,错误:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用Windows XP pro连接到托管在服务器上的SQL Server 2000数据库时,我总是收到上述错误。客户端PC(我的工作环境)是Windows 7。



到目前为止,我已经使用Visual Studio 2010和Net framework 4.0开发了我的应用程序。
全部正常工作。然后我安装了Visual Studio Express 2012 for Web和ASP.NET 4.5。



现在,当我尝试通过 SqlConnection conConnection .Open()我得到例外:

 与服务器成功建立连接, 
,但是在登录前握手期间发生错误。
(提供者:TCP提供程序,错误:0 -
远程主机强制关闭现有连接。)

请注意第二条消息,因为我发现很少的信息: 现有的连接被远程主机强行关闭



我还没有成功尝试过无数解决方案,其中包括:




  • 各种连接字符串(Encrypt = false;)

  • netsh WinSock显示目录> winsocks.txt(在这里似乎没有发现任何奇怪的应用程序)

  • netsh Winsock在客户端和服务器上重置

  • 从Visual Studio中重新构建应用程序,定位为Net 4.0 / Net 4.5

  • 使用Visual Studio开发服务器或本地IIS Web服务器

  • IIS重置,重新启动客户端和服务器pc变量次

  • 检查SQL Server 2000属性,连接,日志,分析器...



还有其他coul d我尝试下一步而不卸载Net 4.5(和Visual Studio 2012)?






重要的附加信息< h2>

同一个应用程序部署在生产服务器(Windows 7,IIS 7.5,Net Framework 4.0)中。
实际在生产中的应用程序是使用Visual Studio 2010,net 4.0编译的,并正确连接,没有错误(幸运的是)!
所以,在安装VS Express 2012和Asp.net 4.5之后,我的客户端机器出现了问题。 (我也试图用VS2010打开并重新编译解决方案,但我也得到同样的例外)。






编辑



为了测试目的,我已将我的应用程序(VS 2012 / Net 4.0编译)部署到生产服务器当然没有安装Net 4.5)。
为此,我创建了一个新的网站,将应用程序池设置为集成管道并定位到Net Framework v4.0.30319。
现在,此测试网站成功连接到我的测试SQL Server数据库(SQL 2000),也连接到我的生产服务器数据库(SQL7)。
Clue:


问题仅在我的客户端PC上,而罪魁祸首是Net 4.5?







编辑2



通过视觉连接Studio 2010或2012 Server Explorer,数据源:Microsoft SQL Server(SqlClient)提供相同的异常(只有不同​​的是现在是登录前握手超时)。



< img src =https://i.stack.imgur.com/qdLOS.pngalt =enter image description here>



Microsoft SQL Server Management Studio 2008工作正常!(服务器类型:数据库引擎;服务器名称:myserver\SQL2000;验证:SQL Server身份验证;登录:密码)



解决方案

我本质上有同样的问题。 ASP.NET项目在Visual Studio 2010中的Win 7计算机上成功运行,但移动到运行Visual Studio 2012的Windows 8框中。运行时由VS转换项目会抛出上述SQL Server错误消息。 SQL服务器是远程的,但两个客户端(Win 7和Win 8)都在同一网络上。一件作品,另一件作品。



在IIS中的两台机器上进行比较设置我发现Web应用程序正在使用的应用程序池的配置有所不同。 Identity属性默认为ApplicationPoolIdentity,但如果将其更改为NetworkService,则问题已解决。希望这将有助于别人,因为我已经进行了广泛的搜索,没有发现任何指向这一点。


I always get the above error when trying to connect to a SQL server 2000 database hosted on a "server" with Windows XP pro. The client pc (my working environment) is Windows 7.

Up to now I have developed my application using Visual Studio 2010 and Net framework 4.0. All was working correctly. Then I have installed Visual Studio Express 2012 for Web and ASP.NET 4.5.

Now, when i try to connect via SqlConnection conConnection .Open() i get the Exception:

A connection was successfully established with the server, 
but then an error occurred during the pre-login handshake. 
(provider: TCP Provider, error: 0 - 
An existing connection was forcibly closed by the remote host.)

Please note the second message, because I have found very little info on that: An existing connection was forcibly closed by the remote host.

I have yet unsuccessfully tried a myriad solutions, including:

  • Various connection strings (Encrypt=false; )
  • netsh WinSock Show Catalog > winsocks.txt (don't seem to spot any strange application here)
  • netsh Winsock reset on both client and server
  • Rebuilding the app from Visual Studio targeting Net 4.0 / Net 4.5
  • Use Visual Studio Development Server or Local IIS Web Server
  • IIS reset, restarting Client and Server pc variuos times
  • Checked the SQL Server 2000 properties, connections, logs, profiler...

What other could I try next without disinstalling Net 4.5 (and Visual Studio 2012)?


Important additional info

This same application is deployed in a production server (Windows 7, IIS 7.5, Net framework 4.0). The application actually in production was compiled with Visual Studio 2010, net 4.0, and is connecting correctly with no errors (thankfully)! So, the problem has arisen on my client machine after I have installed VS Express 2012 and Asp.net 4.5. (I have also tried to open and recompile the solution with VS2010, but I get the same exception).


EDIT

For testing purpose, I have deployed my application, compiled with VS 2012 / Net 4.0, to the "production" server (on which I have never installed Net 4.5 of course). For this I have created a new Web Site, with Application pool set to Integrated pipeline and targeting Net Framework v4.0.30319. Now, this test web site connect successfully to my test SQL Server database (SQL 2000) and also to my production server database (SQL7). Clue:

the problem resides only on my client pc, and the culprit is Net 4.5?


EDIT 2

Connecting via Visual Studio 2010 or 2012 Server Explorer, Data Source: Microsoft SQL Server (SqlClient) gives the same Exception (only difference is that now is pre-login handshake timeout).

Instead Connecting from Microsoft SQL Server Management Studio 2008 works fine! (Server type: Database engine; Server name: myserver\SQL2000; Authentication: SQL Server Auth; Login: Password)

How can be that the connection from SQL Server Management Studio works fine?

解决方案

I am essentially having the same problem. ASP.NET Project that runs successfully on a Win 7 computer in visual studio 2010 but moved to a Windows 8 box running Visual Studio 2012. Project is converted by VS when running it throws the SQL server error message described above. SQL server is remote but both clients (Win 7 and Win 8) are local on the same network. One works and the other doesn't.

Comparing setup on both machines in IIS I found that there is a difference between the configuration of the Application Pool in use by the web application. The Identity property defaults to "ApplicationPoolIdentity" but if you change it to "NetworkService" then the problem is resolved. Hopefully this will help someone else as I have done an extensive search and found nothing that pointed to this.

这篇关于与服务器成功建立连接,但是在登录前握手期间发生错误。 TCP提供程序,错误:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆