Charles Willwerth
Mar 23, 2020Brass Contributor
Random CSOM 503 errors
Hello,
I am seeing random 503 errors in Fiddler when running CSOM code. As an example (using PnP ExecuteQueryRetry):
using (var clientContext = new ClientContext(url))
{
// (code to add credentials goes here)
clientContext.Load(clientContext.Web);
var web = clientContext.Web;
var list = web.Lists.GetByTitle("Status");
clientContext.Load(list);
var StatusTask = list.GetItemById(2665); // using this item just to test
clientContext.Load(StatusTask, item => item["Status"]);
clientContext.ExecuteQueryRetry();
if (StatusTask["Status"].ToString() == "Status") // this is where I get a C# error, but in Fiddler I can already see the 503 error
{
// do stuff
}
}
This code works the vast majority of the time, but sometimes errors out, and it's only one call against SharePoint. If we have a process that runs ExecuteQuery() dozens of times (and we do), it lowers our success rate quite a bit.
I've noticed various threads on Twitter today having this issue but wanted to post here in case other people are looking.
Example twitter threads: