wazo-platform / wazo-res-stasis-amqp

Asterisk module to publish stasis events to an AMQP server
GNU General Public License v2.0
5 stars 6 forks source link

Not all AMI events are sent to AMQP #18

Open niksabaldun opened 4 years ago

niksabaldun commented 4 years ago

I am reading messages from RabbitMQ and I noticed that many AMI events are missing. The ones I've noticed so far:

Newchannel Newstate DialBegin DialState DialEnd Hangup

I am receiving events like FullyBooted, VarSet, SuccessfulAuth, UserEvent, DeviceStateChange.

Asterisk version is 16.7.0 and RabbitMQ is configured as follows:

rabbitmqadmin declare exchange name=asterisk.topic type=topic durable=true
rabbitmqadmin declare queue name=asterisk durable=true
rabbitmqadmin declare binding source=asterisk.topic destination=asterisk routing_key=stasis.ami.*
safchain commented 4 years ago

I had a quick look. Only AMI events that are publish on the stasis bus internally by Asterisk are publish to AMQP. The reason is that this module subscribes to the stasis bus to forward them to AMQP.

https://github.com/wazo-platform/wazo-res-stasis-amqp/blob/master/res_stasis_amqp.c#L666

sboily commented 4 years ago

@safchain not sure to understand your answer, you think not all Asterisk modules send their events on the stasis bus. I remember when i did the first version i received all events from stasis, but this is long time ago so i'm not sure, i don't remember ... So if it the issue, this module will work correctly only after update all asterisk module sending AMI events on stasis. But looks like strange for me.

safchain commented 4 years ago

@sboily @niksabaldun digging a bit more in the Asterisk code, In fact it seems to be that way, some AMI event are generated from stasis event then not send back to stasis. Here the Hangup event gdb backtrace

#0  channel_state_change (old_snapshot=<optimized out>, new_snapshot=0x7fff9400cde8) at manager_channels.c:573
#1  0x00000000004f283d in channel_snapshot_update (data=<optimized out>, sub=<optimized out>, message=<optimized out>) at manager_channels.c:742
#2  0x000000000056ac64 in router_dispatch (data=0x8da0f0, sub=0x8da190, message=0x7fff940118d8) at stasis_message_router.c:199
#3  0x000000000055c380 in dispatch_exec_async (local=<optimized out>) at stasis.c:1043

This comment seems to confirm this: https://github.com/asterisk/asterisk/blob/master/main/manager_channels.c#L25

sboily commented 4 years ago

Ok so we also listening channels state on the module. Check if you have what you need on the routing_key channel.#.

niksabaldun commented 4 years ago

@sboily I've already checked the channel routing key and it's not any more helpful. I also made a little debugging session and the problem is definitely in Asterisk. Some modules do not send AMI events to stasis, and I doubt they ever did. It's great that Asterisk exists, but internally it is an inconsistent mess, and we'll probably die of old age before that gets fixed. I'll try to see if there is a more reliable way of subscribing to manager events than ast_manager_get_topic().

sboily commented 4 years ago

@niksabaldun if it can help you we have an AMI proxy to amqp here: https://github.com/wazo-platform/wazo-amid

niksabaldun commented 4 years ago

@sboily Thanks. I already have such utility that I made myself, but Asterisk module is more reliable. I'll try and see if I can modify it. I'll make a pull request if I am successful.

sboily commented 4 years ago

Yes i'm agree, that why we worked on this module. We are using with ARI but will be nice to have all events on AMI.

antonwantstosleep commented 4 years ago

Hi to all!

What about this issue? @sboily, did you get any success with making changes?

antonwantstosleep commented 4 years ago

By the way - is there any opportunity to get https://github.com/wazo-platform/wazo-amid as a bin daemon for linux x64? I am not familiar with docker...

sboily commented 4 years ago

Hello, i'm not sure to understand your last question, wazo-amid is a python daemon, so there is no platform restriction. About this issue, we haven't time to work on it this last weeks because we are working a lot with ARI for the moment. But this is on my todo.