Azure HTTP request timeout workaround

前端 未结 2 1877
终归单人心
终归单人心 2021-01-26 14:16

We currently have an application hosted on a Azure VM instance.

This application sometimes processes long-running and idle HTTP requests. This is causing an issue becau

相关标签:
2条回答
  • 2021-01-26 14:42

    As a simple workaround, I had my script send a newline character every 5 seconds or so to keep the connection alive.

    Example:

    set_time_limit(60 * 30);
    ini_set("zlib.output_compression", 0);
    ini_set("implicit_flush", 1);
    
    function flushBuffers()
    {
        @ob_end_flush();
        @ob_flush();
        @flush();
        @ob_start();
    }
    
    function azureWorkaround($char = "\n")
    {
        echo $char;
        flushBuffers();
    }
    
    $html = '';
    $employees = getEmployees();
    foreach($employee in $employees) {
        html .= getReportHtmlForEmployee($employee);
        azureWorkaround();
    }
    
    echo $html;
    
    0 讨论(0)
  • 2021-01-26 14:47

    The Azure Load Balancer now supports configurable TCP Idle timeout for your Cloud Services and Virtual Machines. This feature can be configured using the Service Management API, PowerShell or the service model.

    For more information check the announcement at http://azure.microsoft.com/blog/2014/08/14/new-configurable-idle-timeout-for-azure-load-balancer/

    0 讨论(0)
提交回复
热议问题