0

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 still 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>
dinwal
  • 467
  • 2
  • 14

2 Answers2

2

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

Community
  • 1
  • 1
knightpfhor
  • 9,299
  • 3
  • 29
  • 42
  • In my case the connection stays active as I continuously keep checking on the queue storage (kind of polling to check if the work is over). It's just that the results from the overlay function do not display in the label. I wonder if there is a setting that renders the label unaccessible from the code. – dinwal Oct 15 '11 at 01:06
  • If you are actually getting back a result from your ajax call and it's just not setting the value as you expect, then this will be an issue with how you're trying to set the value. It's hard to say what the issue is without seeing your HTML, but I would try just setting the value of #results on the button click to make sure that is correct. – knightpfhor Oct 16 '11 at 19:37
0

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.

Community
  • 1
  • 1
jdecuyper
  • 3,934
  • 9
  • 39
  • 51