Cannot get rid of "physical connection is not usable" exception

asp.net-mvc entity-framework ioc-container sql-server unity-container

Question

I am about to shoot myself. Spent few weeks now trying to solve this issue. We have an ASP.NET MVC 4 web app that uses SQL Server 2012 and Entity Framework as ORM and Unity for IoC. Web app is hosted on Amazon EC2. I started getting "Physical connection is not usable" exception. It happens few times a day. I searched many articles and forums and tried all the possible suggestions:

  • Tried removing pooling from connection string "Polling=False"
  • Tried limiting pool size and connection lifetime
  • Tried changing LifetimeManager of Unity to HierarchicalLifetimeManager, PerRequestLifetimeManager. Also made sure entities context is disposed after the end of request
  • Removed all TransactionScope references

When exception happens, the only way to restore application is to restart server, which is very bad!!!

This is full exception:

A transport-level error has occurred when sending the request to the server. (provider: Session Provider, error: 19 - Physical connection is not usable)

1
25
3/28/2014 1:43:05 PM

Accepted Answer

I confirm now, by changing connection string on the server to use "." for data source instead of domain name, exception seem to have disappeared. Very weird as domain name used to work before. Must be some sort of update on SQL Server

7
4/7/2014 2:51:23 AM

Popular Answer

I know this is an old post but I've recently had a horrible time with this error and there were no solutions on any of the blogs.

Specific details about my problem: ASP.NET web app with target .NET framework 4.5, MVC ver. 5.2.3, Entity ver. 6.0.0.0, MS SQLServer Express 2014. My dev system is running Windows 7 Pro SP1.

Symptoms: The error came on suddenly (I had not worked on the project for almost three weeks, at which time it had functioned fine). When I started the app, after logging the user in, the second query sent to the database by the Entity framework ALLWAYS generated the error "A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)". It did not matter which table was queried. The error was not intermittent and rebooting the server did not help. The error occurred using IIS and IIS express.

SqlConnection.ClearAllPools() prevented the error for ONE query only, and I did not want to add this before every single Entity call in the program. I tried every single solution on all the blogs to no avail, even solutions to other Transport-Level Errors. I rolled back package updates for my references in an attempt to get back to a working state. Nothing!

The Solution: The culprit was Microsoft SQL Server 2014 SP1 Security update (KB3070446)!! I rolled back this update and everything worked like a charm!

I lost two days of dev work dealing with this problem, hopefully this post can help someone else avoid this agony!



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow