I get this error when executing a HTTP Client Request from BC Code: "Code: 0, Message: NavHttpClient Request Failed, Error: The operation was canceled.". The error is thrown after what looks like (more or less) precisely 2 minutes. If I limit my request in BC so that it takes less than 2 minutes, it completes without errors.
If I send the exact same (full) request from Postman, it succeeds after about 4 minutes.
I've tried changing all 2 minute timeout values found in the Business Central Administration to 1:02:00, but to no avail:
- Client Services/Keep Alive Interval
- OData Services/DeltaServiceClientTimeout
- Asynchronous Processing/Page Background Task Default Timeout
Per default, Postman does not impose a timeout (File/Settings/Request timeout in ms is 0). If I change that to e.g. 10 seconds, Postman throws an error as expected: "Error: Response timed out/ESOCKETTIMEDOUT".
In Postman, two keys are set in the header: "Connection = keep-alive" and "Accept = */*". I am sending those from BC as well.
I'm convinced the issue is somehow related to a 2 minute timeout somewhere - please help me find it!
Answers
Client: HttpClient;
Client.Timeout := 5 * 60 * 1000; // 5 minutes timeout
What you should note is that the max. setting is determined by the NavHttpClientMaxTimeout setting on the servicetier. This is also 2 minutes by default. If you try to set the value in code to anything larger than the setting on the servicetier, you get a runtime error.
Senior NAV Developer
Elbek & Vejrup