Azure HTTP请求超时解决方法 [英] Azure HTTP request timeout workaround

查看:81
本文介绍了Azure HTTP请求超时解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前在Azure VM实例上托管了一个应用程序.

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

此应用程序有时会处理长时间运行且空闲的HTTP请求.这引起了一个问题,因为 Azure将关闭闲置时间超过几分钟的所有连接.

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.

我已经看到一些有关设置较低的TCP保持活动率的建议.我已经尝试过

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.

有什么建议吗?我们的VM正在运行Server 2008 R2.

Any suggestions? Our VM is running Server 2008 R2.

推荐答案

作为一个简单的解决方法,我让我的脚本每5秒发送一个换行符以保持连接有效.

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

示例:

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;

这篇关于Azure HTTP请求超时解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆