Nancy Server偶尔会因NullReferenceException而崩溃

时间:2018-03-14 13:23:23

标签: c# owin nancy httplistener

我们有一项似乎不时死亡的服务,目前似乎每天都会死,但过去发生的频率较低,但仍然是一个问题。它似乎是负载最大的服务器,我们的其他服务器都没有遇到此问题。我们得到它的例外

2018-03-14 11:06:09,574 [9] FATAL Topshelf.Runtime.Windows.WindowsServiceHost The service threw an unhandled exception
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Net.HttpListener.EndGetContext(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.<ProcessRequestsAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

目前还没有关于我们的代码的哪个部分被调用的其他信息。这似乎是一个相当低级的南希问题,所以我只是希望其他人有任何想法或者之前遇到过这个问题?

服务可以在失败后重新启动并正常工作,因此似乎是一个短暂的问题。

1 个答案:

答案 0 :(得分:1)

据我所知,异常并未指出Nancy代码中的任何位置,但很可能在调用Nancy处理程序之前。它可能是您的OWIN配置或在Nancy之前运行的其他处理程序的问题。

我的经验告诉我们:

  • 检查你的Owin和Nancy管道,特别是创建和销毁运行时的动态对象,
  • 另请参阅您的操作系统的事件日志 - 可能还会有其他内容过早杀死您的服务,
  • 尝试运行探查器并收集有关运行时行为的详细信息 - 关注内存使用情况
  • 尝试增强您的日志记录,至少尝试定义包含nancy的owin中间件的边界。

只要看到一个简单的堆栈跟踪,我就可以说了。祝你好运!

相关问题