I have a Azure function calling Service fabric API using HttpClient API exposed in API management service. But the API management service logs shows that the API call failed with the problem ID "ClientConnectionFailure at forward-request".
On the client side I receive System.Net.Sockets.SocketException with error message "The operation was canceled. Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request. The I/O operation has been aborted because of either a thread exit or an application request"
What are the possible reasons for this failure? How to fix it? Unfortunately I couldn't find enough documentation on this?
First you have to under stand that in APIM we have client which could be your browser or any other tool, the APIM proxy that forwards the requests to the back-end and the back-end that hosts your application.
The reason behind the client connection failure is that the client dropp the connection before receiving the response from the APIM proxy.
Two reasons might cause the client to drop the connection
The APIM gateway takes long time to respond due to heavy load at the APIM gateway or at the back-end referred by the APIM instance does not have enough processing bower to handle the requests forwarded by the APIM gateway so the client times out.
The client drops the connection for any reason while receiving the response from the APIM proxy.
You have to identify what reason is causing this and based on that you need to react by either fixing your client or to salcale up your APIM or your back-end.
I had similar issue. In my case sales force is the client and I have observed this error often. Sales forces closes connection if it does not get a response within 5 seconds of call. This fails the request at APIM level and error "ClientConnectionFailure at forward-request" is observed.
Please check for how long does you'r client wait for the response. If APIM takes longer than that is the same issue.
to cater this you need to either increase wait time at client side or work on improving response time of APIM.