开发者

Azure web role receiving results from a long process

My Azure web role uses Ajax to call a function (in default.aspx.cs) that delegates work to worker roles. Worker roles may take up to 30-40 minutes depending on input file selected by user. If the worker roles return the result quickly it is received by the webrole and displays correctly on the web page. If it takes long the results are sti开发者_如何学运维ll received by the webrole (tried printing to trace) but nothing gets displayed on the web page.

I feel there is some kind of time out that kills the connection between the ajax code on the page and the webrole.

The code looks like:

    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
         $("#btnSubmit").click(function () {
            var params = '{ map1 : "' + document.getElementById('<%=ddlMap1.ClientID %>').value + '",' +
                    'map2 : "' + document.getElementById('<%=ddlMap2.ClientID %>').value + '",' +
                    'op : "' + document.getElementById('<%=ddlOperator.ClientID %>').value + '"}';
            $('#spinner').show();
            $('#results').text('');
            $.ajax({
                type: "POST",
                url: "Default.aspx/Overlay",
                data: params,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    var dmsg = '';
                    if (msg == null) {
                        dmsg = 'null';
                    } else {
                        dmsg = msg.d;
                    }
                    $('#spinner').hide();
                    $('#results').text(dmsg);
                },
                error: function (error) {
                    $('#results').text('');
                }
            });
        });
    });
    </script>


The azure load balancer kills any inactive connections after 1 minute. See my answer to this question about how to work around this problem.


I would try to override the default timeout value of jquery to see if it helps:

$.ajaxSetup({
  timeout: 3600000 // one hour
});

This issue could be caused by jquery but also be dependent on browser and network settings as stated in this SO question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜