Sharepoint Online ClinetContext.ExecuteQuery causes connection reset - asp.net

I have an ASP.NET application hosted in IIS calling Sharepoint using ClientContext. On a production deployment, a call to ExecuteQuery causes the ASP.NET to throw net::ERR_CONNECTION_RESET. On the server, the following exception was thrown:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__6.MoveNext()
Cannot complete this action. Please try again.
There is no other trace of any other error, except this.
I have tried setting TLS1.2 with no success.
I have also tried using a delay before the call to ExecuteQuery and the result was still a failure.
Can anyone suggest what could be going wrong here?
Note: it works perfectly on my local machine.

After spending a few valuable hours, I found the solution. One of the fields had a wrong date time value and Sharepoint, on the flip side, without throwing a meaningful exception, just caused the request in IIS to abruptly close.

Related

ASP.NET Ajax Control Toolkit - capturing unhandled exceptions?

I inherited an ASP.NET (.NET 4.7.2) application. It has Elastic rigged-up (via the Javascript API) to capture APM data and errors from the front-end.
The top offending errors in Elastic for months now have been:
Uncaught Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404 (but sometimes it will say 503).
Both refer to ScriptResource.axd as being the "culprit".
On the one hand, it sure would be nice if I could find out exactly WHAT resource or URL was being requested... as well as which page in my app is doing the requesting.... when such an error occurs.
But I'm at the point now where... as an alternative, I'd just be happy to change these from being unhandled exceptions to handled ones. (I don't think our users are actually having any serious issues from these. The major page for this app is one that updates a couple of key update panels once every 8 seconds. So, occasional failures of those requests are somewhat expected. Users would have already raised hell if something major was going on.)
I'd much rather see any errors in Elastic that are coming from our own Javascript code than from the Ajax Control Toolkit.
So, does anyone know how I might capture these?
I THINK I've finally found the right information (though some of these pages are from 2008). How to basically add a custom error handler to the Script Manager:
Script Manager 4.5 handling errors
https://social.msdn.microsoft.com/Forums/en-US/59a34e36-f80b-4344-a793-8ea2ce21abe2/ajax-exception-handling?forum=aspdotnetajax
Handle Asynch error messages with ScriptManager
https://blog.digitaltools.com/post/2010/02/03/Unhide-Exceptions-Hidden-By-AJAX.aspx
Looks like I should be able to either bury the exceptions... or get more details on them and pass them on through to get thrown to Elastic.
I think my biggest hurdle right now would be to actually try to recreate these errors myself (preferably in a non-prod environment). But I guess I'll figure that out somehow.
Thanks!

Strange Code first Migration behavior, or IIS issue?

Ok, so the background is this.
I have created a hardware controller for a fingerprint reader, and a web application that allows users that have scanned in to do things in the web application. The web application was created using Code First, and the communication is done through signalr 2.0 The problem that I am having is this. Everything works beautifully for about a day, this used to be about half a day, but in IIS 7.0 I changed the idle time on the application pool to 200 mins, but I am still getting an error at random times on the web server, I have managed to have extended the amount of time that is stays running. However, what confuses me, and why I cannot seem to get a handle on what is happening is that when it does go down;
A) I do not know why? (I am leaning towards a timeout somewhere)
B) The error message is the same one you get when you make a change to the database structure and forget to use Database-Update from the package manager console, Yet no one is changing the database.
c) If you leave it alone it will fix itself, and I do not know why or how.
Has anyone seen behavior like this? and if so what caused it and how did you fix it? Or can anyone offer how I can debug this?
Thanks so much for any help!
Kelso
If the exception is "The model backing the 'YourContext' context has changed since the database was created. Consider using Code First Migrations to update the database" you could try to catch that exception and log the content of the following method and compare it to the return value of the method in Application_Start or whenever it worked for you.
((System.Data.Entity.DbContext)(context)).InternalContext.QueryForModel(0)
The method gives you a XML representation of your database schema.
Just to update on this issue, it turns out that the IIS server had been set to only a single CPU and a single thread, (VMare setting) and that thread was getting hung, and could not create a new thread to continue processing, once we updated the cpu's and increased the thread count to 5, everything works like a dream.

Webservice throws "empty" exception

I've a webservice which seems to works fine, but sometimes the webservice stop working for no apparent reason. When I check the response in Firebug I see an "empty" exception:
"There was an error processing the request"
When the error occurs none of the methods on the webservice is working - even the simplest methods which does nothing else but return some data from the database. What could cause a webservice to completly stop working?
Best regards,
Steffen
I'd same problems a few years ago. By using PerfMon I saw that I've to increase the usable memory for the hosting AppPool..
When you're logic is fine, it has to be a configuration problem on your webserver (IIS)

ServerError due to Memory issues?

In my Project (ASP.NET, VB.NET), sometimes a Server Error is showing.
When this error is shown, Users cannot submit their Applications, so that they have to re-type full details and submit again.
How can I escape from these Server Errors?
I think the reason may be Memory issues. Because if the user try to submit again (after Sign Out->Sign In ) then they can submit. Daily twice or thrice Error is happening.
The word "Server" in the phrase "Server Error" refers to your ASP.NET code. You are the server!
If you are running .NET 2.0 or later, you can look into the Application event log (use the Event Viewer applet) for warnings from "ASP.NET". They will include details of what went wrong.
You need to debug your code to find out what's causing this, but the event logs will give you a starting point.
"Server Error" is just a generic message that indicates the the server code (your code) threw an exception that wasn't handled. It shows the user "server error" instead of a specific message so that no implementation details are exposed to outside users.
In other words, without debugging or looking at a log file or something, all you can tell from "Server Error" is that an Exception of any type was thrown.
Sorry, but the information you provided is not helpful in determining the issue.
I think that you'll need to provide a bit more info to get meaningful solutions.
Do you have server logs?
Can you debug through the app as the error occurs?
Does the error occur at a certain time of day, or after a certain regular action?
Does your app attempt to write to a file that may not be accessible?
is it possible that you are experiencing memory issues?
the list could go on, best to do some more investigation and if a more specific issue comes to light edit your question with the extra detail.
AFTER EDIT:
From the extra detail you've provided I wouldn't jump to memory as an issue, in signing out and back in the user is refreshing their session so everything is reset. If you are not seeing anything in your logs you'll need to look at your exception/error handling.
You just haven't provided enough info yet for us to work out the root issue, let alone suggest a solution. That's what you're seeing from all the answers here thus far. Find the event log info and there should be something there to help you, or at least something more to post here.
Try debugging the error? Server Error can be caused by various reasons.
Check for potential infinite loops.
Check for code in the constructor that might fail (especially for web services).
I think I've had cases like this which led to 'Server Error'. I'm assuming you mean the big red 'Server Error' message?
Save all your files and close your Visual Studio and now right click on Visual studio and run as administrator. It worked for me.

Debugging ASP.NET Timeout

I need to debug an asp.net website following a timeout, i.e. via a breakpoint placed in the .aspx page that is specified as the loginURL setting in forms authentication config.
However, I understand that when debug="true" the site will not timeout (link text)
So how can I debug timeout scenarios?
Thanks.
I guess you are interested in finding out which part of the code is slow enough to cause the request to time out. If you step through it line-by-line in debug mode, you should be able to identify which line is causing the problem, even though the 'timeout' exception will not get triggered.
If time-outs are the problem, why not use the standard trace functionality in ASP.NET? Using the trace information enables you to determine where the most time is spent. This may help to identify the bottleneck.
See here for an example of tracing in ASP.NET.
re: "Thanks for the replies above, although rather than identifying what is causing the timeout, I need to actually cause a timeout and trace through code following the timeout.
A problem has been reported whereby following a timeout and logging back in to the site, some strange behaviour has been observed which I am trying to identify."
Perhaps there is no way to do this in debug mode then. Trace might be useful, or adding in lots of commands to log information to a file so you can later see what was happening.
One other thought: Are your users pressing the back button after getting the timeout error? In some situations this could lead to unexpected behaviour.

Resources