1

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.

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

1 Comment

Hi - thank you for your kind reply. Yes, I had tried all the timeout settings. It was timing out after 1.5 mins. In the end, the problem was solved by using client callable settings. Thanks again. +1 for the input.
0

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.

In my case, I needed to add this in the Upgrade Actions as per the below code

using (SPSite site = new SPSite(siteURL))
using (SPWeb web = site.OpenWeb())
{
      site.WebApplication.ClientCallableSettings.ExecutionTimeout = TimeSpan.FromMinutes(60);
      site.WebApplication.ClientCallableSettings.MaxObjectPaths = 1000;
      site.WebApplication.ClientCallableSettings.MaxResourcesPerRequest = 1000;
      site.WebApplication.ClientCallableSettings.EnableStackTrace = true;
      site.WebApplication.Update();
}

5 Comments

OK, but how do you get the SPWebApplication ?
The best solution is to use Server Object Modeal instead of Client Object Model .With Server Object Model you won't face these problems and won't need to tweak/change SP settings and you'll avoid a lot of headache.
@JosephCaruana Can you post your solution, what exactly did you do with ClientCallable settings? The link that you have in the answer just has the declaration of the property
@JosephCaruana could you give a snippet for how you used clientcallablesettings ExecutionTimeout ?
@AhmedHussein, I have updated my answer to include a code sample - hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.