IIS crashes on cancellation

65 views
Skip to first unread message

John Ligtenberg

unread,
Feb 12, 2021, 12:27:50 PM2/12/21
to Abot Web Crawler
Hello,

When I call the cancel method in a static class in an ASP.NET site in which Abot runs, IIS crashes.

The relevant code:

private static CancellationTokenSource _cancellationTokenSource;

In the method which call Abot:

_cancellationTokenSource = new CancellationTokenSource();

 var result = await crawler.CrawlAsync(new Uri(startPage), _cancellationTokenSource);

A method in the static class initiates cancelling:

public static string Cancel()
{
try
{
if (_cancellationTokenSource == null)
{
return _message += "<br>_cancellationTokenSource was null<br><br>";
}

Task.Run(() => _cancellationTokenSource.Cancel());

_isRunning = false;

return _message += "<br>Cancelled error checking<br><br>";

}
catch (Exception ex)
{
_logger.Log(Level.Error, ex.Message, ex);
return _message += "<br><br>Error cancelling crawl<br><br>";
}
}

What can I do to prevent IIS crashing?

Yours,

John Ligtenberg

sjdi...@gmail.com

unread,
Feb 13, 2021, 7:33:17 PM2/13/21
to John Ligtenberg, Abot Web Crawler
Can you give more information about the crash? Is there a specific exception thrown? What do the logs say?

--
You received this message because you are subscribed to the Google Groups "Abot Web Crawler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abot-web-crawl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abot-web-crawler/e3843989-a247-4aa9-a1b9-8bf036e815ffn%40googlegroups.com.

John Ligtenberg

unread,
Feb 16, 2021, 3:25:28 AM2/16/21
to Abot Web Crawler
First:

System.OperationCanceledException
   bij System.Threading.CancellationToken.ThrowOperationCanceledException()
   bij Abot2.Crawler.WebCrawler.ThrowIfCancellationRequested()
   bij Abot2.Crawler.WebCrawler+<ProcessPage>d__65.MoveNext()
   bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bij System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   bij System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   bij Abot2.Crawler.WebCrawler+<<CrawlSite>b__64_0>d.MoveNext()
   bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bij System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   bij System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   bij System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   bij System.Threading.ThreadPoolWorkQueue.Dispatch()


And subsequently:


Faulting application name: w3wp.exe, version: 10.0.19041.1, time stamp: 0x58c67bf3
Faulting module name: KERNELBASE.dll, version: 10.0.19041.662, time stamp: 0xec58f015
Exception code: 0xe0434352
Fault offset: 0x000000000002d759
Faulting process id: 0x2f1c
Faulting application start time: 0x01d7043a77121450
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: ea3a6c94-e682-45ce-a40d-40a0c4e36cb2
Faulting package full name: 
Faulting package-relative application ID: 

John Ligtenberg

unread,
Feb 23, 2021, 4:26:15 AM2/23/21
to Abot Web Crawler
Is there any other way to stop the crawling process ?

sjdi...@gmail.com

unread,
Feb 23, 2021, 2:49:06 PM2/23/21
to John Ligtenberg, Abot Web Crawler
Anyone that cancels a task using a cancellationtoken (nothing to do with Abot/Abotx) will have to catch the cancellation exceptions that are thrown. Again, this has nothing to do with Abot, the cancellation token hook is just so Abot can play nicely in a larger cancellation process. You can stop Abot independently by setting the args.CrawlContext.IsCrawlStop or args.CrawlContext.IsHardStopRequested properties to true. The CrawlContext object is available in every event. You can see the difference between the two properties by reading the comments for each.

        private static void PageCrawlCompleted(object sender, PageCrawlCompletedArgs e)
        {
            e.CrawlContext.IsHardStopRequested = true;
        }

Reply all
Reply to author
Forward
0 new messages