Trying to determine why I'm seeing several thousand connections to SQL Server port 1433 via netstat in the time_wait state. I know that tcp/ip connections in the time_wait state signify connections that were closed, and waiting a configurable period of time before releasing the connections in case there are delayed packets that haven't yet arrived on a socket.
Here's some background. Running SQL Server 2008 R2. I have a C++ application using ATL/OLE DB to connect to the SQL Server Database. The C++ application is making dozens of requests per second to SQL Server, but it always uses the same connection.
Looking at SQL Server Profiler and monitoring Login and Logoff events for my application, I can see periodically lots of rapid fire logins and logoffs sporadically every once in a while with my application as the Application Name. Yet setting breakpoints in my code where the connection to a database occurs, that code to connect to the DB is never executed more than once at startup. If I shut my application down completely, these login/logoff events stop.
I'm really perplexed.. I know I can adjust the tcp time_wait settings in the registry and lower the number of seconds the ports are in the time_wait state, but I'm really trying to understand why these seemingly random login and logoff events are occurring. The login and logoff events are matching up with the number of connections shown with netstat in the time_wait state..
Any suggestions at all would be greatly appreciated.