5

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. 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.)".

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". Having in mind the information in msdn and over the internet my understanding is that when "." 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?

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

klashar
  • 2,519
  • 2
  • 28
  • 38
Todor Petrov
  • 51
  • 1
  • 3

1 Answers1

4

You should look on your server at sys.dm_exec_connections and see what net transport is actually being used by your clients.

Normally the client tries SM if local server, then tries NP and then 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! 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. The system event log and the ERRORLOG may contain more information at the time when this problem occurred.

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.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • First thanks for the answer. What I am trying to understand though is in what scenarios the Sql Client throws an exception. E.g. when SM protocol fails, next attempt is with named pipes and we have an exception because it is disabled on the server, but isn't is a failure and therefore try with TCP? Also if we have max allowed timeout 10 secs we won't try 10 secs for each protocol. In one word which failures will cause an attempt with next protocol and which will cause an immediate exception? – Todor Petrov Apr 18 '11 at 08:23