且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"信号灯超时时间已过期" SQL Azure的

更新时间:2023-02-26 16:16:37

SQL Azure的比对premise SQL很大的不同。当SQL Azure的服务器超载或出现故障,它会断开的连接数,当你重新连接,你会被发送到另一个SQL Server。

Azure SQL is very different than on premise SQL. When an Azure SQL Server gets overloaded or goes down, it will disconnect a number of connections and when you reconnect you will get sent to another SQL Server.

然而,随着TCP连接,你不知道的另一端已终止,除非你真正发下来它的信息,这就是为什么这个错误发生的连接。

However with TCP connections you don't know if the other end has terminated the connection unless you actually send information down it, which is why this error occurs.

一旦你的code知道连接被终止,它建立在一个查询新的连接,这将工作得很好。

Once your code know the connection is terminated, it establishes a new connection on the next query, which will work just fine.

通过实体框架6现在可以处理Transient使用故障实体框架与SQL Azure的处理

With Entity Framework 6 you can now deal with Transient Fault Handling with SQL Azure using Entity Framework

在您的DBConfiguration类,你需要设置你的SetExecutionStrategy并进行配置。只是在你的项目中创建一个新的类,并从DbConfiguration继承。

In your DBConfiguration class you need to set your SetExecutionStrategy and configure it. Just create a new class in your project and inherit from DbConfiguration.

public class MyConfiguration : DbConfiguration 
{ 
    public MyConfiguration() 
    { 
        SetExecutionStrategy( 
            "System.Data.SqlClient", 
            () => new SqlAzureExecutionStrategy(1, TimeSpan.FromSeconds(30))); 
    } 
}

连接灵活性的全部细节/重试逻辑(EF6起)