2012-07-31 169 views
1

我收到来自Sharepoint客户端托管对象模型的超时。Sharepoint客户端模型 - 请求超时

Microsoft.SharePoint.Client.ServerException: The operation has timed out. 

基本上,我正在批量处理100个更新并一次发送它们。如果需要时间,对我来说没有问题,但我真的想要避免超时异常。

我尝试了百万种方法来增加客户端上下文中的超时,但他们都没有成功。我使用反射来尝试标识共享点在调用客户端上下文的executequery方法时正在执行的操作。共享点基本上是创建一个HttpWebRequest并发送它。

我曾与下面的代码结束了,但还是没有成功:

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  

} 

但我仍然收到超时错误!
请问我还有什么其他的东西吗?


任何援助将不胜感激。

回答

0

的解决方案是使用clientcallablesettings(SPWebApplication.ClientCallableSettings):
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.clientcallablesettings.aspx
这具有的执行超时属性和其它相关设置。

+1

好的,但您如何获得SPWebApplication? – Vroomfundel 2013-09-30 14:41:53

+0

嗨添加引用sharepoint.administration – 2013-09-30 18:43:01

+0

最好的解决方案是使用服务器对象模式,而不是客户端对象模型。使用服务器对象模型,你将不会面临这些问题,并不需要调整/更改SP设置,你会避免很多头痛。 – Zakos 2015-05-06 08:05:31

1

你试过

  • 保持默认的KeepAlive(真),
  • 禁止超时和
  • 保持默认MaxServicePointIdleTime值(也就是100秒 默认值,但您设置为2)。

正如:

public static void SetInfiniteTimeout(this ClientContext ctx) 
{ 
    ctx.RequestTimeout = -1; //ctx.RequestTimeout or System.Threading.Timeout.Infinite; 
} 

而且,多少秒需要让你得到超时错误,在当前的配置?

+0

嗨,谢谢你的回复。是的,我试过了所有的超时设置。它在1.5分钟后超时。最终,问题通过使用客户端可调用设置来解决。再次感谢。输入+1。 – 2012-08-11 05:28:01