将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