FastAGI ReRoute Problem

I am trying to reroute the call over another server in case of failure via FastAGI.

First I send

Exec(“Dial”, “SIP/” + “” + “/” + request.Extension + “,” + Call_TimeOut)

then call fails for some reason , at this moment i would like to decide if to reroute this call over another carrier or not according to the release cause.

But Asterisk does not hangs up the call and waits AGIServer to complete that routing process.
Hangup event is fired after AgiServer process is completed so i can’t find a way to get release cause of the call.

Is there a way around this situation?

Best Regards

Hi again
Although Call wasn’t ended but i tried to retrive “HANGUPCAUSE” variable via GetVariableCommand AGI command.
I succesfully retrieved “HANGUPCAUSE” with this way