title: Asterisk AMI events sometimes missing
body: <p>I have a Python service which connects to Asterisk via AMI and listens for events to detect when a call has begun.</p>
  <p>This seems to work on most of the Asterisk servers I connect to.  However, on a few of our servers we just don't see any of the AMI events (e.g. <code>Newstate</code>) when the call happens, though we do later see the <code>Cdr</code> event once the call has completed.</p>
  <p>I've confirmed that this isn't specific to the library we're using to connect to AMI (<a href="https://pypi.org/project/py-Asterisk/" rel="nofollow noreferrer">py-Asterisk</a>), because I see exactly the same thing when I connect manually, e.g.</p>
  <pre><code>$ openssl s_client -connect my-asterisk-server:5039
  ...
  Asterisk Call Manager/2.10.3
  Action: Login
  Username: manager
  Secret: ThisIsWhereITypedTheActualPassword
  
  Response: Success
  Message: Authentication accepted
  
  Event: FullyBooted
  Privilege: system,all
  Status: Fully Booted
  
  Action: Events
  EventMask: on
  
  Response: Success
  Events: on
  </code></pre>
  <p>In the above block, I manually connected to AMI, logged in as the same administrator my Python code is using, and ensured that all events are turned on (though my asterisk config should already be displaying all events I care about by default).</p>
  <p>After this point what I see on some of my Asterisk servers is a series of expected events like <code>Newstate</code>, followed by an eventual <code>Cdr</code> event.  On other servers, I see <strong>only</strong> the <code>Cdr</code> event, with nothing proceeding it.  This is completely consistened within each server, meaning a server either always sends all of the expected events or it never does.</p>
  <p>I've checked the versions of asterisk, the <code>manager.conf</code> config file, the <code>extensions.conf</code> dialplan, the asterisk console in verbose mode (i.e. connecting via <code>asterisk -vvvr</code> to the running process), and just generally comparing my config files to my actually-working Asterisk servers.</p>
  <p>I'm stumped as to what could be causing this, or even what to try next.  If it matters, here's what my <code>manager.conf</code> looks like:</p>
  <pre><code>[general]
  tlsenable=yes
  tlsbindaddr=10.0.0.123:5039
  tlscertfile=/etc/pki/asterisk/ami.crt
  tlsprivatekey=/etc/pki/asterisk/ami.key
  
  [admin]
  secret=TheActualPasswordIsOnThisLine
  read=system,call,log,verbose,command,agent,user,originate,cdr
  write=system,call,log,verbose,command,agent,user,originate,cdr
  </code></pre>
  <p>EDIT: After some further digging, it seems that the <strong>only</strong> events which are showing up are <code>Cdr</code> events, so even things like peer registration events don't show up.  I've also confirmed that all of my Asterisk 13.19.0-1 servers are exhibiting this behavior, and the only working servers are running much older versions of Asterisk.</p>
  <p>The weird thing is that calls do come through successfully, so the problem is not that I'm missing some necessary module.  (Or maybe I am?  Is there some &quot;make events show up in AMI&quot; module that I need to ensure is loaded?)</p>
  <p>FURTHER EDIT: I was able to turn on CEL events (Channel Event Logging), and those events show up, but this is a different set of events than the standard <code>Newchannel</code>/<code>Newstate</code>/etc I'm looking for.  In theory I could rewrite a large portion of my service to use the CEL events, but ideally I'd just turn on the standard <code>Newstate</code>/<code>Newchannel</code>/<code>Hangup</code> events.</p>