"信号灯超时时间已过期" SQL Azure的 [英] "The semaphore timeout period has expired" SQL Azure

查看:414
本文介绍了"信号灯超时时间已过期" SQL Azure的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Azure数据库。净MVC的Azure网站使用实体框架6.间歇性(1千元左右的请求),我得到的错误访问System.ComponentModel.Win32Exception:信号灯超时时间已过期

I am running a .Net MVC Azure Web Site with a SQL Azure database accessed using Entity Framework 6. Intermittently (1 in a thousand or so requests), I get the error "System.ComponentModel.Win32Exception: The semaphore timeout period has expired"

System.Data.SqlClient.SqlException:一种传输级错误有
  从服务器接收的结果时发生。 (服务提供商:TCP
  提供程序,error:0 - 信号灯超时时间已过期)--->。
  System.ComponentModel.Win32Exception:信号灯超时时间已
  过期

System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) ---> System.ComponentModel.Win32Exception: The semaphore timeout period has expired

有似乎没有理由的前后误差及其与SQL Azure的互动都很好请求。有什么办法来处理或解决这个问题。

There seems to be no reason for it and requests before and after the error and their interactions with SQL Azure are fine. Is there any way to handle or resolve this.

推荐答案

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现在可以处理<一个href=\"http://stackoverflow.com/questions/12282427/transient-fault-handling-with-sql-azure-using-entity-framework\">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起)

这篇关于&QUOT;信号灯超时时间已过期&QUOT; SQL Azure的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆