This project is read-only.
1

Closed

ObjectDisposedException from sendToAsterisk

description

sometimes the socket to the Asterisk server seems to be disposed.

stacktrace:

at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at Asterisk.NET.IO.SocketConnection.Write(String s) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\IO\SocketConnection.cs:line 159
at Asterisk.NET.Manager.ManagerConnection.sendToAsterisk(String buffer) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1833
at Asterisk.NET.Manager.ManagerConnection.SendToAsterisk(ManagerAction action, String internalActionId) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1825
at Asterisk.NET.Manager.ManagerConnection.SendAction(ManagerAction action, ResponseHandler responseHandler) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1675
at Asterisk.NET.Manager.ManagerConnection.SendAction(ManagerAction action, Int32 timeOut) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1639
at Asterisk.NET.Manager.ManagerConnection.login(Int32 timeout) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1242
at Asterisk.NET.Manager.ManagerConnection.Login(Int32 timeout) in d:\Projecten\Vsc-mmx\Template\Asterisk.Net\Asterisk.Net\Manager\ManagerConnection.cs:line 1571


The asterisk manager is maintained by an always running thread.

Seems like something went wrong with the mrConnector.CallerThread which got the stopped state, and therefore die is set to true:

ManagerReader.cs #248
                            if (mrConnector.TraceCallerThread && mrConnector.CallerThread != null && mrConnector.CallerThread.ThreadState == ThreadState.Stopped)
                            {
                                die = true;
                                break;
                            }
Closed Aug 6, 2014 at 11:51 AM by skrusty

comments

skrusty wrote Mar 16, 2014 at 4:55 PM

Can you please provide the following:-
  • version of asternet
  • version of asterisk
  • steps to reproduce the issue, i.e. any specific actions that cause the problem, etc.

skrusty wrote May 13, 2014 at 8:42 AM

See comments in discussion: https://asternet.codeplex.com/discussions/540343

Thanks. I've got logging running at the moment (massive file).

In ManagerConnection.cs I changed this line and reliability has improved dramatically this morning :
private bool traceCallerThread = true;
to
private bool traceCallerThread = false;
In the ChangeLog there is a note about this feature: 09.18.2008 Fix error with Close Windows.Forms without Logoff() - to disable this feature set TraceCallerThread property to false.

The calling thread gets monitored to see whether it has stopped and when it has the "while (!die)" loop is terminated causing the socket to be closed.

Under my Windows service the calling thread sometimes has a threadstate of stopped. I'm trying to work out now why the calling thread is stopped since the service continues to run without problem.