Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4.5 forms app connecting to SQL Server 2012 fails: SSL Provider, error: 0

I have a problem connection to a SQL Server 2012 instance running on Windows Server 2012. I have a .NET 4.5 windows forms application installed on a client machine running Windows 7. The error I get is this:

A connection was successfully established with the server, but then an error 
occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - 
The wait operation timed out.)

My connection string looks like this:

server=SERVERNAME;database=DATABASENAME;User Id=someuser;password=somepassword;Timeout=60;app=LabelMaker

I tried connecting to the SQL Server from the client machine using QueryExpress and that worked! My app is 64-bit if that is of any help. I've checked every setting I can think of in SQL Server. No force encryptions are enabled on the protocols (shared memory and tcp/ip), the domain firewall is open on the server. I've tried various connection strings with all kinds of unheard off parameters, always the same result, failure.

I'm really confused about why it works with QueryExpress? My app works when connected to a remote instance of SQL SERVER Express on another machine, it also works if I run it on the SQL Server 2012 machine.

I've also tried connecting to the server from the client machine with LinqPad and this is also really weird, with the new version based on net4/4.5 (Version: 4.43.06) it fails but when I use the old version of Linqpad (2.x) based on net3.5 it works!

It seems like Panda Security is causing the problem, I ran

netsh winsock show catalog 

and found a few panda entries, I then did a reset

netsh winsock reset

now my application works fine, I then rebooted the machine, ran the catalog command again, the panda entries were back and my app is having the same problem as before.

Here are the Panda entries in the winsock catalogue: https://gist.github.com/pellehenriksson/5159883

All ideas and suggestions are appreciated.

UPDATE

Panda Security v5 is the cause of this problem, this has been confirmed by Panda support. The root cause of the problem is explained by Alex below. The customer will do an upgrade to v6 of Panda Security, I will test again after the upgrade.

CONCLUSION Moving to Panda Security v6.0 fixed this issue.

like image 643
Pelle Avatar asked Mar 13 '13 18:03

Pelle


2 Answers

This seems to be a non-Microsoft related issue: Visual Studio 11 beta installation disabled my abillity to connect remote MS SQL Server but not local databases.

The ticket has been closed as external.

The only workaround available at this time on Microsoft Connect is:

Posted by Lars Joakim Nilsson on 5/4/2012 at 5:03 AM

My machine had this problem. The work around for me was to remove non-IFS LSP installed Winsock Catalog Provider. Se http://support.microsoft.com/kb/2568167 /Lars Nilsson

The SetFileCompletionNotificationModes API causes an IO completion port not work correctly with a non-IFS LSP installed link gives the resolution:

Not specifying the FILE_SKIP_COMPLETION_PORT_ON_SUCCESS flag or removing any non-IFS Winsock LSPs installed. Also moving from a non-IFS LSP to Windows Filter Platform (WFP) can resolve this issue.

So, you should remove Panda Security or, as an alternative, you may try to execute netsh winsock reset as a pre-build command (although I'm not sure if this is effective without a reboot), which would let you develop/debug your application.

[UPDATE]

More information about application compatibility is given here: Application Compatibility in the .NET Framework 4.5:

Data

SQLClient

Feature

Ability to connect to a SQL Server database from managed code that runs under the .NET Framework 4.5.

Change

The existing synchronous API code path was modified to add asynchronous support.

Impact

The presence of non-IFS Winsock Base Service Providers (BSPs) or Layered Service Providers (LSPs) may interfere with the ability to connect to SQL Server. For more information, see SetFileCompletionNotificationModes API causes an IO completion port not work correctly with a non-IFS LSP installed on the Microsoft Support website.

like image 118
Alex Filipovici Avatar answered Nov 01 '22 18:11

Alex Filipovici


I hate to say it, but restarting Visual Studio and my Microsoft SQL Server Management Studio solved this problem.

like image 45
Josh Lowe Avatar answered Nov 01 '22 18:11

Josh Lowe