简体   繁体   English

SQL Server共享内存通信协议用法

[英]SQL Server Shared Memory communication protocol usage

I read a lot of articles and answers of similar topics over the internet but didn't find the reason for my problem. 我通过互联网阅读了很多类似主题的文章和答案,但没有找到我的问题的原因。

I have a .NET 4 Windows Service connecting to SQL Server Express on the same machine. 我有一台.NET 4 Windows服务连接到同一台机器上的SQL Server Express。 Only one time in production it happened to see the following error: 生产中只有一次碰巧看到以下错误:

"A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)". “已成功与服务器建立连接,但在登录过程中发生错误。(提供程序:命名管道提供程序,错误:0 - 管道的另一端没有进程。)”。

The reason for having this error is clear if we use named pipes protocol because we haven't enabled them on the server. 如果我们使用命名管道协议,则出现此错误的原因很明显,因为我们尚未在服务器上启用它们。 But my question here is why named pipes protocol could be used here? 但我的问题是为什么命名管道协议可以在这里使用? In the connection string we have used " Data Source=.\\SQLEXPRESS ". 在连接字符串中,我们使用了“ Data Source =。\\ SQLEXPRESS ”。 Having in mind the information in msdn and over the internet my understanding is that when "." 考虑到msdn和互联网上的信息,我的理解是当“。” is used always the "Shared Memory Protocol" must be used. 总是使用“共享内存协议”必须使用。 So what must happen so that ADO.NET SqlClient decides to use Named Pipe Protocol instead? 那么必须发生什么才能使ADO.NET SqlClient决定使用命名管道协议呢?

Most of the times everything is working just fine, but I need to know the process so that we can prevent any further errors of this type if needed. 大多数时候一切都工作正常,但我需要知道这个过程,以便我们可以在需要时防止此类型的任何进一步错误。

Thanks in advance, Todor 提前谢谢,托多尔

You should look on your server at sys.dm_exec_connections and see what net transport is actually being used by your clients. 您应该在sys.dm_exec_connections上查看服务器,并查看客户端实际使用的网络传输。

Normally the client tries SM if local server, then tries NP and then TCP. 通常,客户端尝试SM(如果是本地服务器),然后尝试NP,然后尝试TCP。 Attempting to connect to (local) follow the same rules, if it wouldn't then tools and apps could not connect to a local server if the server does not listen on SM protocol! 尝试连接到(local)遵循相同的规则,如果它不会,那么如果服务器不监听 SM协议,则工具和应用程序无法连接到本地服务器! The fact that you see errors indicating the client attempted NP points to situations when the SM attempt failed, which could happen due to a busy server, or if the server was restarting or something similar. 您看到错误指示客户端尝试NP指向SM尝试失败的情况,这可能是由于服务器繁忙,或者服务器正在重新启动或类似情况。 The system event log and the ERRORLOG may contain more information at the time when this problem occurred. 系统事件日志和ERRORLOG可能在发生此问题时包含更多信息。

You can enforce the client to use a specific protocol by modifying the connection string, as per How to use the server name parameter in a connection string to specify the client network library , use servername=lpc:.\\SQLEXPRESS to force Shared Memory only. 您可以通过修改连接字符串来强制客户端使用特定协议,根据如何使用连接字符串中的服务器名称参数指定客户端网络库 ,使用servername=lpc:.\\SQLEXPRESS仅强制共享内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM