將Azure與SQL Server結合使用。在30%的隱式調用SimpleRoleProvider的情況下,我們得到一個錯誤:命名管道提供程序,錯誤:40 - 無法打開與SQL Server的連接。錯誤頻繁發生但不可重現。它看起來像一個超時..Azure和SQL Server:命名管道提供程序,錯誤:40 - 無法打開與SQL Server的連接
[Authorize(Roles = "Administrator")]
public class AdminController : Controller
{
...
}
堆棧跟蹤看起來像:
[Win32Exception (0x80004005): Access is denied]
[SQLEXCEPTION(0x80131904):在與SQL Server建立連接時出現與網絡相關的或特定於實例的錯誤。服務器未找到或無法訪問。驗證實例名稱是否正確,並將SQL Server配置爲允許遠程連接。 (提供程序:命名管道提供程序,錯誤:40 - 無法打開與SQL Server的連接)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException異常,布爾breakConnection,操作1 wrapCloseInAction) +5296071 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +889 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +225 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +558 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +67 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1052 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1重試,DbConnectionOptions userOptions,DbConnectionInternal &連接) 78 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(的DbConnection owningConnection,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1重試,DbConnectionOptions USEROPTIONS)143 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重試)83 System.Data.SqlClient的.SqlConnection.Open()+86 System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext上下文,Boolean revertImpersonate)+88 System.Web.DataAccess.SqlConnectionHelper.GetConnectio (字符串用戶名)+240 System.Web.Security.RolePrincipal.IsInRole(String,String) (String role)+9461104
我們在自己的服務器上沒有這個問題。這是一個配置問題?我們正在使用免費的Azure版本。
---加成---
壞事是,MVC框架「處理」的要求,在給定的(角色 管理)的例子。框架的使用是添加一個抽象層來方便地處理「域請求」。那麼在這種情況下該怎麼辦?
在此先感謝您的幫助!
奇怪,但我們感覺使用IExplorer(與Chrome比較)發生錯誤的頻率更高。 – Gerard
我不認爲這是瀏覽器相關的問題。你從哪裏連接到數據庫?你的網絡服務器是否爲前提? – QFDev
該數據庫是一個Azure數據庫。是的,你是對的,它不能成爲瀏覽器的問題。儘管如此,統計學上,Chrome的效果更好(!?!?) – Gerard