Delay on failed extension

Hai Everyone,

I have an asterisk server installed with Asterisk 16.7.0. I am using asterisk manger to make the outgoing calls and Once the the calling party answer the call it will excute my dialplan flow and if the call fails then it excuting the failed extension and print the failed call details.

In the Above case is facing 2 issues.

  1. The Start time and Enddtime for the failed calls are coming that when the failed extension exuted.
    example : IF the call dialed at 06-10-2020 19:00:00 and the call fail (BUSY,NOANSWER) and my
    failed extension exuted from the dailplan at 06-10-2020 19:00:55. In the CDR if i search with uniqueid which am prining in the failed extension it gives me starttime and enddtime as 06-10-2020 19:00:55.

2.Some of the time noticed that. The failed extension is calling with large delay.
Example : When we have initated the call 06-10-2020 19:00:00 (on asterisk log) and if the call failed and recived the SIP message from the telecom operator at 06-10-2020 19:00:55 but the failed extension excuted after 4 minitues like 06-10-2020 19:04:00.

Can anyone help on the above. Thanks in advance.

Regarding the 2nd point - I have also noticed that Most of the call which have this issue have received the disconnection from SIP trunk provider with SIP response 400 Bad request.