SQL connection forcibly closed while receiving results - asp.net

I've been having some connectivity issues recently with my website. And today I finally received SOME idea as to what the issue may be. I got this error message while trying to log in.
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
So the question is, what could be causing this error message to get generated?
This only ever seems to occur under high user load. CPU, RAM, and network traffic do not seem to be maxed out.

This error very very often occurs straight after you have had a connection break (e.g. the server terminated the connection, your server process had the KILL command run against it or the network connection between you and the server was broken), and especially if your client is using connection pooling in those circumstances.
So try looking at what happened prior to the error you're seeing.

Related

Facing connection issues with ASP.NET SignalR

My SignalR server (ASP.NET) and client (ASP.NET) both are working fine as excepted but multiple times on a daily basis, I'm getting the following two errors at the end of the SignalR client (ASP.NET):
System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
System.Net.WebException: The request was aborted: The connection was closed unexpectedly.
I've looked in the following ways but still unable to find out the root cause
Check High CPU usage when the error occurred.
Tried to send lots of data to the Server but received all the data received successfully at the Client through the Server.
Checked server is not creating unnecessary connections. Only max three connections are there.

How do I solve a WSAECONNRESET error?

I am using Perforce as part of a small development team. Everyone was able to connect to the P4V client except for one person who gets the following error:
TCP receive failed.
read: socket: WSAECONNRESET
We have deactivated his McAfee firewall and virus scan, but the error persists. I really don't know what to do with this error and it seems to be rather undocumented on the perforce website. From what I gather, it's because it's not a perforce-specific issue, but rather a TCP communication problem that might be caused by something else.
Any tips?
a TCP communication problem that might be caused by something else.
This is possible, or it's possible that whenever this user connects it causes some sort of server fault.
https://msdn.microsoft.com/en-us/library/ms740668.aspx
WSAECONNRESET 10054 Connection reset by peer.
An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
Beyond the usual connection troubleshooting questions (is this user on the same subnet? same version of the client software? same exact P4PORT setting? is the user able to connect via the command line client and if not does it give a more helpful error? why is this user unlike all other users?) I'd look at the server logs to see if it's logging any sort of more helpful error when this user tries to connect.

What exactly is an instance-specific error

Okay so I got:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server.
Now I know what the problem is (web server couldn't see the database server), however I'm wondering what exactly an instance specific error is and if people have examples? I know it's specific to an instance but what kind of things would fall under that?
Instance in this context means an instance of SQL Server. As you remember, SQL server can be installed in multiple instances on the same machine. Instances are adressed machinename\instancename or by IP x.y.z.t:instanceport.
The error means that the instance you are trying to connect cannot be reached while this is unknown whether or not other instances are running and can be contacted. Thus the
"instance specific" error.
How to Troubleshoot Connecting to the SQL Server Database Engine is a good article about troubleshooting the exception you reference in your question. It summarizes the causes to the following:
This error usually means that the SQL Server computer can't be found
or that the TCP port number is either not known, or is not the correct
port number, or is blocked by a firewall.
If you go through the troubleshooting steps, you will find out that the place to search for the problem is not only network related, but it could be, for example:
the database engine not being configured to accept remote connections on the specific instance
the used protocol not being enabled (for example TCP/IP) on the specific instance
I guess that the exception message tries to keep your troubleshooting focus on more than one option when it comes to put the the finger on the certain culprit subsystem. Or maybe it's just a way of reporting a connection related exception which is impossible to trace.

Tracking down database connection issues

Background
We have a number of web applications on different web servers that connect to a single database server. Over the past couple months, we have noticed that every once in awhile, our web servers won't be able to connect to the database server.
Our Environment
We have a couple different web environments, some running ColdFusion and others running .NET. The .NET apps are both Web Forms and MVC. They span multiple versions from 2.0 to 4.5. Both the ColdFusion and .NET web servers are windows based machines. Both the ColdFusion and .NET web environments are clustered and some of the machines are physical while others are virtual.
Our database server is SQL Server 2008 r2. It houses multiple databases. Each application has its own database user that it connects with to the server that only gives it access to a particular database.
Other Facts
When we notice issues, they occur in short bursts that last anywhere from a couple seconds to a couple minutes.
When we notice issues, the burst contains errors from multiple different appliations, not just one app at at time.
When we notice issues, the burst contains errors from applications from different web environments. (This makes us think we can rule out that the apps themselves are the issue)
The burst of connection issues happen at various times throughout the day and night. They are not always during times of high usage.
We have monitored things like number of user connections, memory, IO, CPU usage, etc... and we have not seen spikes or anything else that might point to a problem.
We have installed wireshark on the web and db servers in hopes of catching the problem without any success.
Questions
Does anyone have suggestions on where I should look next?
Are there properties of the database that could cause this?
Is there any way to "monitor" the connection between the database and web server in a better manner?
Is there anything that can be done on the app side to better understand what is happening?
Errors Caught by Apps
.NET errors
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)
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
ColdFusion errors
Error Executing Database Query. The TCP/IP connection to the host has failed. java.net.ConnectException: Connection timed out: connect The error occurred on line 38.
Error Executing Database Query. Connection reset by peer: socket write error The error occurred on line 91.
Error Executing Database Query. Timed out trying to establish connection The error occurred on line 38.
In CF, I once had an issue like what you were seeing. I had CF on 1 server, and sql 2008 r2 on another server. I would see CF errors like you posted below. To help trace it to a network error I wrote something like this:
1) created a down.bat
tracert serverip
2) I then put a <cftry><cfcatch> around the query.
When the query generated the error I would execute
<cfexecute name="C:\path\to\down.bat" variable="log" timeout="60" />
<cfmail to="ME" from="Server" subject="SQL DOWN">
Server Debugging Info:
------------------------------------------------------------
#now()#
#cfcatch.Detail#
#cfcatch.Message#
#log#
</cfmail>
</cfexecute>
This helped me fix my situation which ended up being hardware at the datacenter.

Why is this error happening a lot "asp.net, sql server"?

I have this error which happen many times on my site:
"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: TCP Provider, error: 0 - An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.)"
My site files are on a server and the database on another server, but on the same network.
Anyone know what may cause this problem and how to solve?
Notes:
- When i restart the website server the problem solve and everything work fine.
- Sure my sql server allow remote connections from this website server
It's a pretty generic error when the application can't get to the database. Perhaps you are leaving connections open after using them? There could be a limit on the amount of concurrent connections by user or server.
It's a networking error of some kind, or you're specifying the instance name incorrectly. I've recently seen both cases. In one case, I had moved a connection string from one system, to another system that had a different instance name installed. In another case, I had a server running in a Virtual Machine - about ten minutes after the machine was resumed from suspension, the machine would lose its DHCP lease (and therefore its connectivity).
It could be just about anything, and you'll have to go find out, perhaps by using a network monitor program like Microsoft Network Monitor 3.2.
I found a good article talking about this error, i think it shows the real reason
Understanding the error “An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.”

Resources