简体   繁体   English

远程调用实体框架中的存储过程时,服务器没有响应

[英]No response from server when calling stored procedure in entity framework remotely

I have a Silverlight web app being hosted on Azure vm on IIS. 我在IIS上的Azure vm上托管了一个Silverlight Web应用程序。 I have another VM that is hosting SQL Server along with other application that the web app interacts with. 我有另一个托管SQL Server的VM以及Web应用程序与之交互的其他应用程序。 I have set up a LAN between these two VMs using Azure Virtual Network. 我使用Azure虚拟网络在这两个VM之间建立了一个LAN。 The vm that is running IIS and hosting web app is also my domain controller and I am using windows authentication to authenticate users in this web app. 运行IIS和托管Web应用程序的虚拟机也是我的域控制器,我使用Windows身份验证来验证此Web应用程序中的用户。 The application makes use of entity framework to execute some stored procedures. 应用程序使用实体框架来执行一些存储过程。

Overall everything seem to work fine when the web app is accessed both locally and remotely, but there is one particular stored procedure that takes around 25 minutes to execute that does not seem to behave properly when executed remotely via this web app. 总的来说,当本地和远程访问Web应用程序时,一切似乎都能正常工作,但是有一个特定的存储过程需要大约25分钟才能执行,当通过此Web应用程序远程执行时似乎行为不正常。 Please keep in mind that this 25 mins is actually the expected time because this stored procedure is dealing with millions of records. 请记住,这25分钟实际上是预期的时间,因为这个存储过程正在处理数百万条记录。

So here is the problem I am having. 所以这就是我遇到的问题。 When this stored procedure is executed from SQL Server Management Studio, it completes in around 25 minutes. 从SQL Server Management Studio执行此存储过程时,它将在大约25分钟内完成。 When I execute this stored procedure from the web app locally by making use of the internal ip of the server that is hosting the app, it competes in around 25 mins, the server sends the response back and the app updates its status. 当我通过使用托管应用程序的服务器的内部ip从本地Web应用程序执行此存储过程时,它将在大约25分钟内竞争,服务器发回响应并且应用程序更新其状态。 But when I execute via web app remotely using server's public ip, although the stored procedure executes and completes within 25 mins on the server, the app never gets response back from the server, keeps staying on busy status. 但是当我使用服务器的公共IP远程通过Web应用程序执行时,虽然存储过程在服务器上执行并在25分钟内完成,但应用程序永远不会从服务器返回响应,保持忙碌状态。

I know the stored procedure executes because I am tracking it in the database server directly and also using sql profiler to track any open connections from entity framework, which is there even after the stored procedure completes execution. 我知道存储过程是执行的,因为我直接在数据库服务器中跟踪它,并且还使用sql profiler跟踪来自实体框架的任何打开的连接,即使在存储过程完成执行之后也存在。 I am also using fiddler to track all HTTP traffics and here is what I see. 我也在使用fiddler跟踪所有HTTP流量,这就是我所看到的。

While executing locally via web app using internal ip 使用内部ip通过Web应用程序在本地执行 在本地执行

while executing remotely via web app using public ip 使用公共IP通过Web应用程序远程执行 在此输入图像描述

All other stored procedures take few seconds to execute and they seem to work both locally and remotely. 所有其他存储过程只需几秒钟即可执行,它们似乎在本地和远程都可以工作。 I am not sure if Azure's endpoint mapping has anything to do with this. 我不确定Azure的端点映射是否与此有关。 When executing this stored procedure I set commandtimeout property to 0. 执行此存储过程时,我将commandtimeout属性设置为0。

Any help would be very appreciated! 任何帮助将非常感谢!

image links: 图片链接:

local execution: http://i.imgur.com/NGNre3T.png 本地执行: http//i.imgur.com/NGNre3T.png

remote execution: http://i.imgur.com/haB3fwm.png 远程执行: http//i.imgur.com/haB3fwm.png

This could be an idle timeout by the Azure load balancer. 这可能是Azure负载均衡器的空闲超时。 Have a look over this page to see if it sheds any light on the problem. 看一下这个页面 ,看看它是否能解决这个问题。 Using the latest version of Azure Powershell, you can check the current timeout setting with: 使用最新版本的Azure Powershell,您可以使用以下命令检查当前超时设置:

Get-AzureVM –ServiceName “your-service-name” –Name “your-vm-name” | Get-AzureEndpoint

Depending on your setup, you might be able to set this up using: 根据您的设置,您可以使用以下方式进行设置:

Set-AzurePublicIP –PublicIPName "the-ip-name" –VM “your-vm-name” -IdleTimeoutInMinutes 15

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM