I've been struggling with this error for just over a month now and can't get it figured out.
Background/Architecture:
- MVC 4 application
- NHibernate
- FluentNHibernate
- SQL Server 2008 R2
- Azure website
Sporadically throughout the day, my views are throwing errors because when they try to read/display properties on my objects, it says:
NHibernate.Exceptions.GenericADOException: could not initialize a collection: [WrestleStat.BL.School.Schedule#54][SQL: SELECT ...(removed to keep this short)....] ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. This failure occurred while attempting to connect to the routing destination. The duration spent while attempting to connect to the original server was - [Pre-Login] initialization=3; handshake=23; [Login] initialization=0; authentication=0; [Post-Login] complete=1; ---> System.ComponentModel.Win32Exception: The wait operation timed out --- End of inner exception stack trace --- at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer() at System.Data.SqlClient.TdsParserStateObject.TryReadByteArray(Byte[] buff, Int32 offset, Int32 len, Int32& totalRead) at System.Data.SqlClient.TdsParserStateObjec
2 weeks ago, I was running my website on AppHarbor, and I thought it was because I was on their "basic" (free) plan. The problem seemed to go away if I'd up my worker threads from 1 to 2. Because of that, I decided to switch over to Azure (I was going to anyway, but not this early). Since the switchover to Azure, the problem has not gone away.
I get approximately a dozen of these errors per day on the site. It appears as though that the errors always occur when the razor views are trying to access properties of an object that it's trying to read/display, as opposed to throwing the error inside the controller trying to retrieve the data. Maybe it has something to do with the lazy loading??? But why would that matter, why would the connection be lost in that extremely short timeframe from retrieving the data, then presenting it on the page?
I'm at a loss on how to debug this issue, because it obviously never happens in my development environment. I'm going to switch over to Dapper eventually, but I'm not able to do/start that for at least another 3 months.
Any ideas here?
Edit: here's the website http://www.wrestlestats.com