AMI events getting merged at random

I’m currently working on collecting and processing AMI events. Sometimes events seems to be merged together.

I’ve checked with wireshark, and the events are also merged in the capture, most likely they get merged in Asterisk.

An example looks like this, where a LocalOptimizationBegin gets merged with a Newexten event. This is just one example, but the types of event does not seem to be important, as it happens with all event types.

Any idea what’s happening, and if there’s a setting I can tweak to make it happen less? I have around 100000 event per hour, on average, if the volume of events generated has anything to do with it.

Event: LocalOptimizationBegin
Privilege: call,all
LocalOneChannel: Local/PhoneNumber1@customerID1-Context1-000007e0;1
LocalOneChannelState: 6
LocalOneChannelStateDesc: Up
LocalOneCallerIDNum: PhoneNumber3
LocalOneCallerIDName: <unknown>
LocalOneConnectedLineNum: +45PhoneNumber2
LocalOneConnectedLineName: PhoneNumber2
LocalOneLanguage: da
LocalOneContext: customerID1-Context1
LocalOneExten: s
LocalOnePriority: 1
LocalOneUniqueid: 1686561065.12584
LocalOneLinkedid: 1686561065.12576
LocalTwoChannel: Local/PhoneNumber1@customerID1-Context1-000007e0;2
LocalTwoChannelState: 6
LocalTwoChannelStateDesc: Up
LocalTwoCallerIDNum: +45PhoneNumber2
LocalTwoCallerIDName: PhoneNumber2
LocalTwoConnectedLineNum: PhoneNumber3
LocalTwoConnectedLineName: <unknown>
LocalTwoLanguage: da
LocalTwoContext: customerID1-inboundToCellphone
LocalTwoExten: PhoneNumber1
LocalTwoPriority: 15
LocalTwoUniqueid: 1686561065.12585
LocalTwoLinkedid: 1686561065.12576
SourceChannel: PJSIP/customerID1-PhoneNumber1-00000bda
SourceChannelState: 6
SourceChannelStateDesc: Up
SourceCallerIDNum:Event: Newexten
Privilege: dialplan,all
Channel: Local/Extension1@customerID1-Context1-000007df;2
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: +45PhoneNumber2
CallerIDName: PhoneNumber2
ConnectedLineNum: PhoneNumber3
ConnectedLineName: <unknown>
Language: da
Context: Context2
Exten: h
Priority: 3
Uniqueid: 1686561065.12583
Linkedid: 1686561065.12576
Extension: h
Application: Hangup
AppData: 16

I’ve been playing around with this issue for some time, and apparently by not getting the dialplan events ( ‘Newexten’ and ‘VarSet’), I reduce the number of events byt about 50%, after which I’ve seen no merged events.

Is it possible, that under load, with many simultaneous events being generated, there’s nothing preventing 2 threads from putting their events out on the network at the same time, and as such, merge the events together, making them unusable?

No, because it doesn’t work like that. Each thread that creates an AMI event doesn’t write it to all the connections. The event goes into a queue that each connection thread works through to send the events out. Only that connection thread is what sends the events.

There’s nothing in the AMI code that stands out as being able to cause such an issue. It’s certainly possible it’s lower level and in the TCP side.

That was kinda also what I expected, that the events were put into a queue, then transmitted one by one.

Still doesn’t make sense though, I’m currently collecting from 5 different Asterisk servers, and the merging occurs on all of them, and it seems to always be a VarSet or Newexten event, that gets merged with something else. Which event is first and second varies through. Eg. sometimes the VarSet event is the one getting another event merged into it, at other times, it’s the VarSet event getting merged into another.

That would likely be because those events are generated the most, and most frequent. Those events themselves are not special beyond that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.