Call Hangs up immediately after start ringing

Hello,
I am developing an application to control asterisk using AMI and AGI. The application place a call from an internal to a public extension (tipically a mobile number) and play message used to deliver notification from a Control Center. I am using AMI to place the call using “originate” command and control the flow using async agi via ami. The application seem to works but when the called user hangup the call, I am not able to place a second call (to any extension number) for a while. If a place the call, the called extension start ringing and suddenly stops as someone refuse the call. If I hangup using ami/agi command, everything works fine. Does someone have an idea on how to investigate that issue ?
I thank you very much for your help.
Regards.
Marco Bisio

This is an Asterisk question, you’ll have better luck on the Asterisk forums:

Check your line without asterisk in the way. Sometimes if the remote user hangups the call might be still open until you hangup. This is a problem of your provider and not asterisk’s and you cannot do much.

The Async parameter in the Originate may control this.

Hello. Thank you so much for the answer. My Originate command is as follow:
sprintf(buffer, “ACTION:ORIGINATE\r\nCHANNEL:SIP/201\r\nCONTEXT:from-internal\r\nEXTEN:70%s\r\nASYNC:YES\r\nVariable: __SIPADDHEADER51=Call-Info: sip:192.168.xxx.xxx\;answer-after=0\r\nPRIORITY:1\r\nACTIONID:98765\r\n\r\n”,foniatelnum);

where foniatelnum is the number of the mobile device to call. Unfortunately, if the called mobile close the call itself, I am not able to place a second call to anyone. As soon as the external line start ringing the party, the call is ended. On AteriskI see softhangup, then hangup, and then normal clearing. As long as I control the flow using async agi, I read I must issue an ASYNCAGI BREAK. But, eve following the documentation, I got an error that says: “Message: Both, Channel and Command are required”. But I found no explanations about it. Do you have any suggestion ?
Thnak you so much.
Regards.
Marco Bisio