Azure HTTP request timeout workaround
Asked Answered
R

2

0

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 because Azure will close all connections that have been idle for longer than a few minutes.

I've seen some suggestions about setting a lower TCP keepalive rate. I've tried setting the this rate to around 45 seconds but my HTTP requests are still being closed.

Any suggestions? Our VM is running Server 2008 R2.

Roadrunner answered 11/9, 2013 at 17:34 Comment(2)
what is the reference for "Azure will close all connections that have been idle for longer than a few minutes." ?Winchell
@dorin blogs.msdn.com/b/cie/archive/2014/02/14/…Shavonneshaw
R
2

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;
Roadrunner answered 20/1, 2014 at 21:27 Comment(2)
Can you provide some code to show how you did this?Shipowner
Updated with example.Roadrunner
L
1

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/

Lactone answered 19/1, 2015 at 18:53 Comment(2)
how to find where my wcf hosted in azure? (Cloud Services or Virtual Machines)Upcast
Can i configure tcp idle timeout for app services(i hosted wcf inside my webapp which uses appservices)?Upcast

© 2022 - 2024 — McMap. All rights reserved.