使用AsterNet连接到Asterisk,我看到了以下内容:
Unhandled Exception:
System.SystemException: Unable to run: socket is null.
at AsterNET.Manager.ManagerReader.Run() in
e:\Projects\Github\AsterNET\Asterisk.2013\Asterisk.NET\Manager\ManagerReader.cs:line 197
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()您可以在ManagerReader.cs的AsterNet代码的第197行看到抛出此异常的代码行。看起来这是在connect() (在ManagerConnection.cs中)启动一个新线程时发生的,但是在ManagerReader.cs中mrSocket不知何故是空的。但是这个异常是从那个新线程抛出的,所以我不能捕获它并处理错误。它只会使我的应用程序崩溃。
所以我有两个问题。首先,我如何防止这种情况发生?我在连接或重新连接的方式上做错了什么吗?其次,有没有可能以某种方式捕捉到这一点,并再次尝试连接?
https://stackoverflow.com/questions/44502144
复制相似问题