Issue with client requesting Azure API Management endpoint - Error: ClientConnectionFailure: at transfer-response

Issue with client requesting Azure API Management endpoint - Error: ClientConnectionFailure: at transfer-response

我有一个 nodejs 客户端向 azure api 管理端点发出请求。我有时会遇到以下异常:

ClientConnectionFailure: at transfer-response

所以我正在使用请求包,并且在客户端中我正在做一个简单的请求:

request({
            method: "GET",
            headers: {
                "contentType": "application/json",
                "Ocp-Apim-Subscription-Key": key
            },
            uri: endpointUrl
        }, function (error, response, body) {
            (...)
        });

那么,是否最终在客户端发生超时,在请求中间,从而导致与 Azure APIM 端点的连接失败? 或者是其他东西?你认为我如何解决这个问题?我考虑过增加请求的超时时间,但我假设在省略超时时,它假设服务器(Azure Function App)的默认超时为 120 秒,对吗?

谢谢。

当后端响应时间过长时,我们已经看到了这种行为。

我的方法是先查看后端,在这种情况下是函数应用程序,查看所用时间,然后查看是否有任何 timeout limit 设置为 APIM。

函数应用程序的超时持续时间由 host.json 项目文件中的 functionTimeout 属性 定义。以下 table 显示了两个计划和两个运行时版本的默认值和最大值(以分钟为单位):

要解决性能问题,请遵循此Troubleshoot slow app performance issues in Azure App Service

ClientConnectionFailure 表明客户端在 APIM 正在处理请求时断开了连接。 at transfer-response 表示这发生在 APIM 向客户端发送响应时。 APIM 默认不缓存 request/response 主体,因此当它向客户端发送响应时,它同时从后端读取它。如果后端响应实际数据的时间太长,这可能会导致客户端断开连接。

此行为纯粹是由客户端决定停止等待数据驱动的。在您发送请求并查看错误之前,检查您在客户端需要多长时间。尝试调整客户端超时。