Phpagi not detecting key press

Hi
Am using php agi with $result = $agi->get_data(‘beep’, 3000, 3); but it not detecting key press by user.
The same code is working fine on local server but not on cloud server. Also other phpagi script on this cloud server is able to detect key press by user.
Code and debug output below

  $socket = fsockopen($pbx,"5038", $errno, $errstr, $timeout); 
 fputs($socket, "Action: Login\r\n");
 fputs($socket, "UserName: user\r\n");     
 fputs($socket, "Secret: password\r\n\r\n");  
                                     
              $wrets=fgets($socket,128);
              fputs($socket, "Action: Originate\r\n" );
              fputs($socket, "Channel: SIP/providerName/$phone\r\n" );  
               fputs($socket, "WaitTime: 50\r\n");
               fputs($socket, "exten: 777\r\n");  
               fputs($socket, "Context: contextName\r\n"); 
               fputs($socket, "CallerID: $id\r\n" );       
               fputs($socket, "Async: yes\r\n\r\n" );                   
              fputs($socket, "Action: Logoff\r\n\r\n");
 sleep (1);
 $wrets=fgets($socket,128);


AGI debug code:
`<SIP/ProviderName>AGI Rx << ANSWER
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/ProviderName> Playing '/path/15.slin' (language 'en')
       > 0x55670a31fe10 -- Strict RTP switching to RTP target address xx.xx.xx.xx:19710 as source
       > 0x55670a31fe10 -- Strict RTP learning complete - Locking on source address xx.xx.xx.xx:19710
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/ProviderName> Playing '/path/15.slin' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << GET DATA beep 3000 3
    -- <SIP/ProviderName> Playing 'beep.gsm' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result= (timeout)
<SIP/ProviderName>AGI Rx << EXEC Playback /path/no_key_press
    -- AGI Script Executing Application: (Playback) Options: (/path/no_key_press)
    -- <SIP/ProviderName> Playing '/path/no_key_press.slin' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/ProviderName> Playing '/path/15.slin' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << GET DATA beep 3000 3
    -- <SIP/ProviderName> Playing 'beep.gsm' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result= (timeout)
<SIP/ProviderName>AGI Rx << EXEC Playback /path/no_key_press
    -- AGI Script Executing Application: (Playback) Options: (/path/no_key_press)
    -- <SIP/ProviderName> Playing '/path/no_key_press.slin' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/ProviderName> Playing '/path/15.slin' (language 'en')
<SIP/ProviderName>AGI Tx >> 200 result=0
<SIP/ProviderName>AGI Rx << GET DATA beep 3000 3
<SIP/ProviderName>AGI Tx >> 511 Command Not Permitted on a dead channel or intercept routine
    -- <SIP/ProviderName>AGI Script /var/lib/asterisk/agi-bin/voice_survey.php completed, returning 4
  == Spawn extension (incoming, 777, 3) exited non-zero on 'SIP/ProviderName'  `

Preformatted text

To use 'Preformatted text' tags in a post (or reply) you can:

  1. Click on the ‘</>’ icon above the text box and type (or paste) over Preformatted text which is selected.
  2. Select a region of text and click on ‘</>.’
  3. Insert a ‘backtick’ before the region and after.

If you want to retain line breaks within the region, enter 3 backticks before and after.

It’s Markdown, if you are familiar with that.

Your code snippet is AMI, not AGI.

What does the DTMF logging show?

@sedwards The code I paste is AMI, and transfers the call to dialplan and the dialplan will then run the PHPAGI script that has the $result = $agi->get_data(‘beep’, 3000, 3);
I just tested again the same code on the local server and it is receiving the DTMF but the cloud server is still not.

@david551 Below is the console debug log that include the DTMF.

<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/PrividerName> Playing '/path/15.slin' (language 'en')
       > 0x7f5e9000a850 -- Strict RTP switching to RTP target address xx.xxx.xx.xx:22430 as source
       > 0x7f5e9000a850 -- Strict RTP learning complete - Locking on source address xx.xx.xx.xx:22430
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/PrividerName> Playing '/path/15.slin' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << GET DATA beep 3000 3
    -- <SIP/PrividerName> Playing 'beep.gsm' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result= (timeout)
<SIP/PrividerName>AGI Rx << EXEC Playback /path/no_key_press
    -- AGI Script Executing Application: (Playback) Options: (/path/no_key_press)
    -- <SIP/PrividerName> Playing '/path/no_key_press.slin' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/PrividerName> Playing '/path/15.slin' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << GET DATA beep 3000 3
    -- <SIP/PrividerName> Playing 'beep.gsm' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result= (timeout)
<SIP/PrividerName>AGI Rx << EXEC Playback /path/no_key_press
    -- AGI Script Executing Application: (Playback) Options: (/path/no_key_press)
    -- <SIP/PrividerName> Playing '/path/no_key_press.slin' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << EXEC Playback /path/15
    -- AGI Script Executing Application: (Playback) Options: (/path/15)
    -- <SIP/PrividerName> Playing '/path/15.slin' (language 'en')
<SIP/PrividerName>AGI Tx >> 200 result=0
<SIP/PrividerName>AGI Rx << GET DATA beep 3000 3
<SIP/PrividerName>AGI Tx >> 511 Command Not Permitted on a dead channel or intercept routine
    -- <SIP/PrividerName>AGI Script /var/lib/asterisk/agi-bin/agiscript.php completed, returning 4
  == Spawn extension (incoming, 777, 3) exited non-zero on 'SIP/PrividerName' ```

Also in general section of sip.conf i have:
dtmfmode=rfc2833
relaxdtmf=yes
rfc2833compensate=yes** and reload Asterisk
still no luck

I did a sip debug and got the result below which seem to indicate that my sip provider (skype) is not delivering the dtmf:
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x0 (nothing), combined - 0x0 (nothing)

The provided log indicates that Asterisk did not detect any DTMF. Either you did not enable DTMF logging, or the problem is upstream of the AGI application.

It also appears to indicate that the call terminated before the GET DATA was issued.

I have enabled dtmf logging as indicated below:
logger show channels

Logger queue limit: 1000

Channel                             Type     Formatter  Status    Configuration
-------                             ----     ---------  ------    -------------
/var/log/asterisk/messages          File     default    Enabled    - NOTICE WARNING ERROR 
                                    Console  default    Enabled    - NOTICE WARNING ERROR VERBOSE DTMF

I actually terminated the call after it did not detect the dtmf for 2 times.

When i make calls to the Asterisk it detect the dtmf, so the problem seem to be with outgoing calls from Asterisk

Rather than guessing what is happening, you need to enable sip debugging, to get the actual SIP and SDP.

Note that chan_sip only has community support, so should not be used for new developments unless there is a relevant limitation with PJSIP.

I have shared the SIP debug info i posted earlier, with the SIP provider and waiting for their feedback. The problem seem to be with them

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