2

最近我开始收到带有以下堆栈跟踪的警报:

消息:线程被中止。

堆栈跟踪:在 System.Net.Connection.CompleteStartConnection(布尔异步,HttpWebRequest httpWebRequest)在 System.Net.Connection.CompleteStartRequest(布尔 onSubmitThread,HttpWebRequest 请求,TriState 需要重新连接)在 System.Net.Connection.SubmitRequest(HttpWebRequest 请求,布尔强制提交) 在 System.Net.HttpWebRequest.SubmitRequest(ServicePoint servicePoint) 在 System.Net.HttpWebRequest.GetResponse() 在 System.Net.ServicePoint.SubmitRequest(HttpWebRequest request, String connName) 在 删除以保护身份

在我看来,在与远程服务器建立实际连接之前,该线程已中止。真的吗?为什么会出现这样的情况——试图缩小问题的范围。

我尝试查找有关该System.Net.Connection.CompleteStartConnection方法的文档,但找不到任何东西。有任何想法吗?

更新:添加调用代码的结构以响应评论。

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = method; request.ContentType = "application/xml";
request.Headers.Add("Foo", "Bar");
request.Proxy = new System.Net.WebProxy(proxyAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

更新 2:此警报仅偶尔出现几分钟,然后消失。

更新 3:我还没有提供的一条重要信息 - 我在更新 1 中显示的代码被计时器上的任务调用。

4

2 回答 2

0

我以前处理过这个问题,通常这表明通过您的客户端调用服务的代码或服务本身正在调用Thread.Abort()(这是不好的做法,但用于缓解连接可能保持打开状态的事实在服务器上)。ThreadAbortExceptionsin service 调用主要发生在线程被明确告知中止时。

我应该补充一点,如果服务器正在中止线程,您通常会将其作为SoapException. 因此,请检查您的代码库以了解Thread.Abort().

于 2015-04-27T20:49:36.967 回答
0

Thanks a lot to @Moby Disk and @Scott Chamberlain for helping me solve this issue.

This issue was caused because the application pool hosting the code I've written up had a Recycling setting with Regular Time Interval (minutes) set to 1740 minutes which equates to 29 hours (the default).

Whenever the worker thread was running during such a recycle, I would see the error (because it would receive a ThreadAbort exception which it didn't handle). Fixing the setting fixed the issue.

于 2015-04-28T23:25:15.573 回答