简体   繁体   English

Intermittent System.ComponentModel.Win32Exception:找不到网络路径

[英]Intermittent System.ComponentModel.Win32Exception: The network path was not found

Since we moved to Azure, we are seeing a couple of issues with our DB. 自从我们迁移到Azure后,我们发现数据库存在一些问题。

System.ComponentModel.Win32Exception: The network path was not found System.ComponentModel.Win32Exception:找不到网络路径

With this call stack: 使用此调用堆栈:

System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: 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) ---> System.ComponentModel.Win32Exception: The network path was not found
   --- 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.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
   at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)

The recommandation was to increase ou tier from S0 to S1, which we did, still didn't help. 建议将ou层从S0增加到S1,我们这样做仍然没有帮助。

The second issue is : 第二个问题是:

System.ComponentModel.Win32Exception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond System.ComponentModel.Win32Exception:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应

Third one is: 第三个是:

System.Data.SqlClient.SqlException: Login failed for user 'MyUserName'. System.Data.SqlClient.SqlException:用户'MyUserName'登录失败。

We tried: 我们尝试了:

public class SqlAzureConfiguration : DbConfiguration
    {
        public SqlAzureConfiguration() {
            SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy()); 
        }
    }

That didn't help. 这没有用。 Any ideas what is the problem and how to address it? 任何想法是什么问题以及如何解决它?

Edit 1 : our site keeps failing now. 编辑1 :我们的网站现在一直在失败。 I took screen shot with the number of DTUs. 我拍了DTU的屏幕截图。 As you can see, we have 20 DTUs, and it keeps failing even at a very low usage level. 正如您所看到的,我们有20个DTU,即使在非常低的使用级别下也会出现故障。

DTU用法

EDIT 2 编辑2

We suspected sessions exceeding limit, we tracked those on AppInsight, still not the issue: 我们怀疑会话超出限制,我们跟踪AppInsight上的会话,仍然不是问题: AppInsight上的会话编号

We have increased the Timeout in the connectionString from: 我们在connectionString中增加了Timeout:

Connection Timeout=30; 连接超时= 30;

to

Connection Timeout=1800; 连接超时= 1800;

and that has helped. 这有帮助。 It has been a week and we haven't seen any issues so far. 已经过了一周,到目前为止我们还没有看到任何问题。

Anyone who has this error, especially on Azure, try adding "tcp:" to the db-server-name in your connection string in your application. 出现此错误的任何人,尤其是在Azure上,尝试将“tcp:”添加到应用程序中的连接字符串中的db-server-name。 This forces the sql client to communicate with the db using tcp. 这会强制sql客户端使用tcp与db通信。 I'm assuming the connection is UDP by default and there can be intermittent connection issues. 我假设默认情况下连接是UDP,并且可能存在间歇性连接问题。 This is a slightly different scenario to what the OP has posted as his connection string has tcp , it is important to try this nevertheless 这与OP发布的情况略有不同,因为他的连接字符串有tcp ,但重要的是尝试这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ComponentModel.Win32Exception:找不到路径 - System.ComponentModel.Win32Exception: Path not found System.ComponentModel.Win32Exception:“拒绝访问” - System.ComponentModel.Win32Exception: „Acces is denied” System.ComponentModel.Win32Exception:访问被拒绝 - System.ComponentModel.Win32Exception : Access is denied 为什么hasExited抛出&#39;System.ComponentModel.Win32Exception&#39;? - Why did hasExited throw 'System.ComponentModel.Win32Exception'? System.ComponentModel.Win32Exception c# - System.ComponentModel.Win32Exception c# 找不到C#Mysql EF6代码优先System.ComponentModel.Win32Exception文件 - C# Mysql EF6 Code First System.ComponentModel.Win32Exception File not Found System.ComponentModel.Win32Exception:访问被拒绝...错误 - System.ComponentModel.Win32Exception: Access is denied… Error System.ComponentModel.Win32Exception Process.Start - System.ComponentModel.Win32Exception Process.Start 启动过程时出现System.ComponentModel.Win32Exception-找不到文件,但是文件存在 - System.ComponentModel.Win32Exception when starting process - file not found, but file exists System.ComponentModel.Win32Exception:访问被拒绝 - System.ComponentModel.Win32Exception: Access is denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM