New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple ManagerConnection Instances #5
Comments
Can you include a code snippet so I can see how you're calling SendAction please. Also, can you confirm you're running the latest version of AsterNET (nuget/release/src etc). Also, just to confirm, this doesn't happen when you're running one manager connection? Does it happen only when both connections are to the same asterisk box? |
I've downloaded the code and I run from it. I have the lastest version there is in codeplex, but I compared with the version on GitHub and it seems the same. I have an abstraction layer to hide useless details to top level software, but it only works with one instance of this. This is an example of program logic: Dim lock as New Object
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim threads As New List(Of Threading.Thread)
Dim queues As New List(Of String)({"queue1", "queue2", "queue3", "queue4"})
Dim tmp As Threading.Thread
For Each c As String In colas
tmp = New Threading.Thread(AddressOf runThread)
threads.Add(tmp)
tmp.Start(c)
Next
End Sub
Private Sub runThread(ByVal q As String)
Dim aux As Centralita
aux = New Centralita()
Dim queue As String = q
Do
SyncLock (lock)
Console.WriteLine(String.Format("Queue: {0}; Agents: {1}", queue, aux.AgentsAvaibleSync(queue)))
End SyncLock
Threading.Thread.Sleep(5000)
Loop
End Sub
Here is fragment of code public int AgentsAvaibleSync(string cola)
{
int members = 0;
lock (lockColas) {
string tmpAcc = DateTime.Now.Ticks.ToString();
QueueStatusAction acc = new QueueStatusAction();
acc.Queue = cola;
acc.ActionId = tmpAcc;
try
{
//_manager.SendAction(acc);
ResponseEvents aux = _manager.SendEventGeneratingAction(acc);
ResponseEvent e;
for (int i = 0; i < aux.Events.Count; i++)
{
e = aux.Events[i];
if (typeof(QueueMemberEvent) == e.GetType())
{
if (((QueueMemberEvent)e).Status == 1)
members += 1;
}
}
}
catch (Exception ex)
{
members = -1;
}
}
return members;
} Also I have an asynchronous method to get the avaible agents, but I receive the same result. It occurs always when I have more than an instance of What am I doing wrong? |
I tend to use SendAction() myself, so I may have to create a small test setup to see if I can replicate your problem. Small points.
|
I usually use SenAction() to do the process async, but in this case, I wanted do it synchronoys to see the process more clearly. If you want, I can send you my abstracion layer of AsterNET to simplify your work.
In others tests I done, I don't use these abstraction layer but I created the ManagerConnection object in the same class that I call AvaibleAgents() and using the correct EventHandlers. It works fine for all threads I want to run at the same time! |
OK, so it works fine without your abstraction layer? Turn on the tracing, and lets see what you get. It may flag up something we've not considered. |
Yes. If I merge all the code into a unique class, it works. I've turned on the tracing, but I don't see anything. Maybe I don't know how read this output |
It's quite verbose I know. Are you seeing anything around the same time as the time-out? Feel free to put some in a gist and link here for me to look at if you want. |
Here is my abstractionLayer https://gist.github.com/5841c7360aa8ba9dede7.git. I programmed it into the same project as AsterNET. I'm Spanish, so in the code may be some variable and function names that are in Spanish. If you don't understand something, feel free to ask me |
I've taken a small step: To fix this I modified the Regular Expression that looks for the version, and now it looks like this: public static Regex ASTERISK_VERSION = new Regex("^Asterisk\\s+\\D*([0-9]+.[0-9]+.[0-9]+|[1-9][0-9]-r[0-9]+).*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); If you could do this modification to the NuGet version of AsterNET, I would use it and all my problems will disappear. Thanks for your work and your help |
Fancy forking, making the change and submitting a pull request? Keeps contributions all nice and attributed. Thanks, |
I've followed your advice. Now, you must have a pull request on Common.cs |
Hi guys,
I'm trying make a service that is an interface to manage some autodialer with one thread per autodialer.
Each autodialer has a managerconnection to an Asterisk server, and some of then could be connected to the same Asterisk.
My problem is when I run more than one thread I always get TimeoutException sending QueueStatusAction to Asterisk via manager.
I've investigated for two weeks debugging the code but I've no idea what can happen
Thank you for your time and help
The text was updated successfully, but these errors were encountered: