Client context from SharePoint Online - running slow in the last days

%3CLINGO-SUB%20id%3D%22lingo-sub-623216%22%20slang%3D%22en-US%22%3EClient%20context%20from%20SharePoint%20Online%20-%20running%20slow%20in%20the%20last%20days%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-623216%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20past%20two%20days%20we're%20having%20issues%20with%20slow%20performances%20with%20the%20CSOM%20C%23%20requests.%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20the%20JSOM%20requests%20we're%20not%20having%20issues%20at%20all.%26nbsp%3B%3C%2FP%3E%3CP%3EExecuting%20the%20%22context.ExecuteQuery()%3B%22%20could%20take%20up%20to%2020%20seconds%20on%20a%20list%20which%20contains%20only%2020%20items.%26nbsp%3B%3C%2FP%3E%3CP%3ENothing%20changed%20in%20the%20code%2C%20and%20the%20lists%20content%20didn't%20changed%20as%20well.%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20happens%20randomly%20-%20which%20means%20that%20one%20time%20it%20can%20take%202%20seconds%2C%20and%20on%20the%20second%20time%20it%20will%20take%2020%20seconds.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20anyone%20had%20the%20same%20issue%20lately%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hi, 

In the past two days we're having issues with slow performances with the CSOM C# requests. 

With the JSOM requests we're not having issues at all. 

Executing the "context.ExecuteQuery();" could take up to 20 seconds on a list which contains only 20 items. 

Nothing changed in the code, and the lists content didn't changed as well. 

This happens randomly - which means that one time it can take 2 seconds, and on the second time it will take 20 seconds. 

 

Did anyone had the same issue lately? 

 

1 Reply

@natali320 I know your post is old but maybe this will help you/someone else in the future.

I had the same problem and it isnt exactly random it is usually the first time the query is made as it makes a call to msoid.[yourdomain].co.uk and msoid.co.uk which dont exist so the wait time is due to it waiting for that connection to time out which is usually 20 seconds - a couple of mins before it actually makes the calls to pull the data from sharepoint which that part is actually really quick

 

You should be able to see this yourself if you run a program like fiddler (https://www.telerik.com/download/fiddler) which allows you to see all the web calls your server is making. Start a trace in fiddler and you'll see right at the point where your code calls the csom ExecuteQuery command it will take forever to realise it cant get to those msoid domains, the 2nd time you make a ExecuteQuery call it will be much faster due to it knowing msoid domains arent accessible

 

To fix this I just had to add those domains in my hostfile to point to my loopback address so it fails straight away

127.0.0.1 msoid.co.uk

127.0.0.1 msoid.[yourdomainname].co.uk

 

Hope that helps