The CrmServiceClient class allows you to connect easily to the Common Data Service and execute the API operations offered by the platform. Depending on your particular implementation, you may need to change the connection timeout. This article explains how to apply a custom timeout to a CrmServiceClient intance.
As I covered in my previous article, the CrmServiceClient class has two important properies: OrganizationServiceProxy and OrganizationWebProxyClient. They may let you change the connection timeout that you are looking for. However, this is not the best practice for new implementations. You should use the CrmServiceClient static property MaxConnectionTimeout:
Previously to the deprecation of OrganizationServiceProxy, you may have used the following option:
The other possible alternative to the CrmServiceClient.MaxConnectionTimeout could be the OrganizationWebProxyClient reference, but I would still not recommend to use this option:
You can download and test this code from my GitHub repository:
Notes: At the time of writing this article, I’m using the package Microsoft.CrmSdk.XrmTooling.CoreAssembly 184.108.40.206 and I’m connecting to an environment whose version is 220.127.116.1144 with 2020 release wave 1 enabled