views:

66

answers:

3

So upon a method call to a webservice, I'm getting this error:

"System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: 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) (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.Data.SqlClient.SqlException: 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) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, Str...)."

What could this possibly be? At first I thought it was coming in locally, but someone below pointed out since the error is wrapped in a ServiceModel.FaultException, it might be on the host end. Is it definitely on their end? Or are there any possible ways this could be on my end?

Look at comments below to find out how troubleshooting has gone so far...

A: 

Seems like you're trying to access your sql server via Named Pipes; this protocol allows you to connect to sql server only if it is in the same subnet. Just change the protocol to tcp.

Denis Valeev
Well, the main thing is, this code HAS worked before, and it all of a sudden stopped, and nothing was changed....I asked someone within the company if it could be on the service's end, but they are not convinced it is
Scott
+1  A: 

Does the service run okay on your dev box, but fails when it's deployed? Maybe there's a difference in firewalls between the two locations and the SQL Server. From a command line, does "TELNET YourSqlServer 1433" give you a blank screen, or does it time out?

If you can verify that the service works somewhere (like visual studio or your dev box), that's somewhere to start - what's different between the working and non-working locations?

If not, does the web service call fail immediately with that message, or does it fail after 30 seconds? A delayed failure suggests a timeout, where an immediate failure is likely configuration.

rwmnau
On both the dev box and the deployed environment, it throws the same exception. It isn't a timeout...it happens within about a second after the service call....im sooo confused
Scott
@Scott - Can you post the connection string you're using? Mask the password or anything else sensitive if you need to.
rwmnau
<add key="CnnStr" value="Server=01-slandau;Trusted_Connection=Yes;Database=p03" /> -- this is the cnnstr in the service project as well as the main web.config to my app
Scott
@Scott Don't forget to include user/password. That would help us determine the true cause of the issue.
Denis Valeev
Usernames and pw's arent in any of my CnnStr's actually in the whole app. The app still connects to the DB though fine for everything. It's taken care of different I guess?
Scott
@Scott - can you include "Network Library=DBMSSOCN;" to your connection string? This will ask the client to use TCP instead of Named Pipes. Also, have you tried to TELNET to the server on port 1433 as I mentioned before? The SQL Server may not be listening properly on the standard port, though if it's a shared server (you didn't mention in your question), that not likely the case as other users would complain in droves.
rwmnau
added full text of the error as an edit above....fyi..thanks again guys for trying to help
Scott
@rwm -- TELNET didnt work for me. dos didnt recognize it as a command to my local server. the main thing is, this has worked before...and just started not working, and that line has never been in the cnnstr
Scott
@Scott - You said it worked before, yet "nothing has changed" - clearly, something has changed and it's process of elimination to figure out what. Adding that to your connection string shouldn't be necessary long term, but it will force TCP, and you can see if that works - then you have somewhere to start troubleshooting. You should probably install a TELNET client on you development workstation to test connectivity that way as well - I'd suspect that there was a network change that's preventing a sql connection on port 1433. Perhaps TCP is disabled in your local SQL Client - maybe?
rwmnau
hmm for some reason it doesn't recognize "Network Library" as a valid element
Scott
@Scott: That's been a supported element of the connection string since SQL 2005. What version of SQL Server are you connecting to?
rwmnau
well its actually telling me its not a valid element through VS2008 static analysis
Scott
+1  A: 

This is on the service end. Moreover those guys don't follow security basics and include internal exception details to soap faults.

Do you use HTTP based transport channel? If so use Fiddler, capture SOAP fault from the service and send it to company as proof that error is on their side. If you use other transport channel or encryption use WCF message logging and again send logged message to company.

Ladislav Mrnka
Thank you so much. However, are you certain this is on their end? -- main reason is I don't want to bug them and have it be a simple fix on our side -- even though ive been banging my head against this for a while and almost positive its on their end.
Scott
Use the logging or Fiddler to find the proof.
Ladislav Mrnka