Sharepoint Client model - request timeout
-
23-06-2021 - |
Question
I am receiving a timeout from the Sharepoint Client Managed Object model.
Microsoft.SharePoint.Client.ServerException: The operation has timed out.
Basically, I am batching 100 updates and sending them at one go. It is no problem for me if takes time but I really want to avoid timeout exception.
I have tried in a million of ways to increase the timeout in the client context but they were all without success. I have used reflection to try to identity what the sharepoint is doing when calling the executequery method of the client context. sharepoint is basically creating an HttpWebRequest and sending it.
I have ended with the below code, but still without success:
public static void SetInfinteTimeout(this ClientContext ctx)
{
int timeout = 10 * 60 * 1000;
ctx.RequestTimeout = timeout;
ctx.PendingRequest.RequestExecutor.RequestKeepAlive = false;
ctx.PendingRequest.RequestExecutor.WebRequest.KeepAlive = false;
ctx.PendingRequest.RequestExecutor.WebRequest.Timeout = timeout;
ctx.PendingRequest.RequestExecutor.WebRequest.ReadWriteTimeout = timeout;
System.Net.ServicePointManager.DefaultConnectionLimit = 200;
System.Net.ServicePointManager.MaxServicePointIdleTime = 2000;
System.Net.ServicePointManager.MaxServicePoints = 1000;
System.Net.ServicePointManager.SetTcpKeepAlive(false, 0, 0);
ServicePointManager.DnsRefreshTimeout = timeout; // 10 minutes
}
But I am still receiving a timeout error!
Is there anything else that I am missing please?
Any assistance would be greatly appreciated.
Solution 2
The solution was to use clientcallablesettings (SPWebApplication.ClientCallableSettings):
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.clientcallablesettings.aspx
This has an execution timeout property and other related settings.
OTHER TIPS
Have you tried
- keeping default KeepAlive (true),
- disabling Timeout and
- keeping default MaxServicePointIdleTime value (which is 100 seconds by default but you set to 2).
Just as:
public static void SetInfiniteTimeout(this ClientContext ctx)
{
ctx.RequestTimeout = -1; //ctx.RequestTimeout or System.Threading.Timeout.Infinite;
}
Also, how many seconds it takes for you to get timeout error, in your current configuration?