简体   繁体   中英

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. I have another VM that is hosting SQL Server along with other application that the web app interacts with. I have set up a LAN between these two VMs using Azure Virtual Network. 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. 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. Please keep in mind that this 25 mins is actually the expected time because this stored procedure is dealing with millions of records.

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. 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. 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.

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. I am also using fiddler to track all HTTP traffics and here is what I see.

While executing locally via web app using internal ip 在本地执行

while executing remotely via web app using public ip 在此输入图像描述

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. When executing this stored procedure I set commandtimeout property to 0.

Any help would be very appreciated!

image links:

local execution: http://i.imgur.com/NGNre3T.png

remote execution: http://i.imgur.com/haB3fwm.png

This could be an idle timeout by the Azure load balancer. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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