Hello,
You cannot handle SIP eventualities by checking the return value of t_relay(); a call to t_relay() will almost always succeed immediately, unless there is an a priori failure out of hand (e.g. cannot send from socket, DNS lookup failure, etc.).
Instead, you must do this in a failure_route:
route { ... t_on_failure("FAILURE_ROUTE");
if(!t_relay()) sl_reply_error(); }
failure_route[FAILURE_ROUTE] { if(t_is_canceled()) exit;
if(t_branch_timeout()) { # Handle your timeout case here.
$ru = new value etc.
t_relay(); exit; } }