Using AsterNet to connect to Asterisk, I've been seeing the following:
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()
You can see the line that throws this exception in the AsterNet code at ManagerReader.cs, line 197. It looks like this happens when connect() (in ManagerConnection.cs) launches a new thread, but mrSocket is somehow null in ManagerReader.cs. But this exception gets thrown from that new thread, so I can't catch it and handle the error. It just crashes my application.
So I have two questions. First, how do I prevent this from happening? Am I doing something wrong with how I connect or reconnect? Second, is it possible to catch this somehow and try the connection again?