使用AsterNet連接到Asterisk的,我已經看到了以下內容:如何從AsterNet防止或捕獲「無法運行:套接字爲空」?
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中)啓動一個新線程,但mrSocket在ManagerReader.cs中某種程度上是空的。但是這個異常是從新線程拋出的,所以我無法捕捉它並處理錯誤。它只是使我的應用程序崩潰。
所以我有兩個問題。首先,我如何防止這種情況發生?我是如何連接或重新連接的?其次,是否有可能以某種方式捕捉到這種情況並再次嘗試連接?
而不共享您的登錄代碼,而實際上是造成這種異常被拋出的代碼的一個例子,它是很難給出任何除了鏈接到AsterNet源代碼之外的其他答案。 – Deantwo
https://github.com/AsterNET/AsterNET/blob/master/Asterisk.2013/Asterisk.NET/Manager/ManagerReader.cs#L197 – Deantwo
如果其他人很好奇:https://github.com/AsterNET/AsterNET /問題/ 107 – Deantwo