Nancy Server 偶尔会因 NullReferenceException 而崩溃
Nancy Server sporadically crashes with NullReferenceException
我们有一项服务似乎时常死机,目前似乎每天都会死机,但过去发生的频率较低,但仍然是一个问题。它似乎是负载最大的服务器,none 我们的其他服务器遇到此问题。我们得到的异常
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()
实际上没有关于此时调用我们代码的哪一部分的其他信息。这似乎是一个很低级的 Nancy 问题,所以我只是希望其他人有任何想法或以前遇到过这个问题?
该服务可以在失败后重新启动并正常工作,因此似乎是一个暂时性问题。
据我所知,异常并未指向 Nancy 代码中的任何位置,但很可能是在调用 Nancy 处理程序之前。您的 OWIN 配置或 Nancy 之前 运行 的其他处理程序可能存在问题。
我的经验告诉我们:
- 检查您的 Owin 和 Nancy 管道,尤其是创建和销毁的动态对象 运行时间,
- 另请查看操作系统的事件日志 - 可能有其他原因过早地终止了您的服务,
- 尝试 运行 分析器并收集有关 运行时间行为的详细信息 - 关注内存使用情况
- 尝试增强日志记录,至少尝试定义包括 nancy 在内的 owin 中间件的边界。
仅通过简单的堆栈跟踪,我就可以说这么多了。祝你好运!
我们有一项服务似乎时常死机,目前似乎每天都会死机,但过去发生的频率较低,但仍然是一个问题。它似乎是负载最大的服务器,none 我们的其他服务器遇到此问题。我们得到的异常
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()
实际上没有关于此时调用我们代码的哪一部分的其他信息。这似乎是一个很低级的 Nancy 问题,所以我只是希望其他人有任何想法或以前遇到过这个问题?
该服务可以在失败后重新启动并正常工作,因此似乎是一个暂时性问题。
据我所知,异常并未指向 Nancy 代码中的任何位置,但很可能是在调用 Nancy 处理程序之前。您的 OWIN 配置或 Nancy 之前 运行 的其他处理程序可能存在问题。
我的经验告诉我们:
- 检查您的 Owin 和 Nancy 管道,尤其是创建和销毁的动态对象 运行时间,
- 另请查看操作系统的事件日志 - 可能有其他原因过早地终止了您的服务,
- 尝试 运行 分析器并收集有关 运行时间行为的详细信息 - 关注内存使用情况
- 尝试增强日志记录,至少尝试定义包括 nancy 在内的 owin 中间件的边界。
仅通过简单的堆栈跟踪,我就可以说这么多了。祝你好运!