0
votes

I have a nodejs client making request to an azure api management endpoint. I am getting the following exception sometimes:

ClientConnectionFailure: at transfer-response

So i am using the request package, and in the client i am doing a straightforward request:

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

So is it a timeout eventually happening in the client, in the middle of the request, and consequently failing the connection with the Azure APIM endpoint? Or something else? And how do you think i could solve this problem? I thought about increase the timeout in the request, but i am assuming that in omission of timeout, it is assuming the default timeout of the server (Azure Function App) that is 120 seconds, right?

Thanks.

2
Does your function take long to process without APIM too? If not, could you check the trace to see what's happening?PramodValavala-MSFT
This is an intermittent issue, so it is hard to trace the request, because i am not able to reproduce it. Also, the back end function, called by the apim instance, is running under standard plan, so i would say it should be fine in terms of performance. According to App Insights, in the last 30 days, the maximum executiond duration of the function was 18,040.338 MS = 0.3 minutes.Hugo Barona

2 Answers

2
votes

ClientConnectionFailure suggests that client broke the connection wile APIM was processing request. at transfer-response means that this happened when APIM was sending response to client. APIM does not cache request/response body by default, so when it's sending response to client it's at the same time reading it from backend. This may lead to client breaking off the connection if backend takes too long to respond with actual data.

This behavior is driven purely by client deciding to stop waiting for data. Check how long it takes for you on client before you send request and see the error. Try adjusting client timeout.

1
votes

We have seen this behavior when the back end is taking too long to respond.

My approach would be to take a look at the backend first which is Function app in this case and see the time taken and then see if there are any timeout limit set at APIM.

The timeout duration of a function app is defined by the functionTimeout property in the host.json project file. The following table shows the default and maximum values in minutes for both plans and in both runtime versions:

enter image description here

For troubleshooting Performance issue , follow this Troubleshoot slow app performance issues in Azure App Service