[OpenSIPS-Users] Nested reply_routes

Malte spce at lard.at
Fri Apr 10 09:31:16 UTC 2026


Hi,

this approach unfortunately doesn't work. Does somebody else know of a 
solution to neaten up big reply routes?

My code and the following error:

>   367route[test] {
>   368xlog("now in test route");
>   369change_reply_status(181, "test");
>   370}
>   371
>   372onreply_route[MAIN] {
>   373# For fr_inv_timeout handling
>   374if (t_check_status("180")) {
>   375$var(180_in_trans)=1;
>   376route(test);
>   377xlog("back to reply route");
>   378}
>
> CRITICAL:core:yyerror: parse error in 
> /etc/opensips/opensips.cfg:369:29-30: Command <change_reply_status> 
> cannot be used in the block

Doing it in a reply route:

>   367onreply_route[test] {
>   368xlog("now in test route");
>   369change_reply_status(181, "test");
>   370}
>   371
>   372onreply_route[MAIN] {
>   373# For fr_inv_timeout handling
>   374if (t_check_status("180")) {
>   375$var(180_in_trans)=1;
>   376t_on_reply("test");
>   377xlog("back to MAIN reply route");
>   378}
>
> ERROR:sipmsgops:change_reply_status_f: the class of provisional or 
> positive final replies cannot be changed

Jump to secondary reply route via proxy route:

>   367route[test] {
>   368xlog("now in test route");
>   369t_on_reply("test");
>   370}
>   371
>   372onreply_route[test] {
>   373xlog("now in test reply route");
>   374change_reply_status(181, "test");
>   375}
>   376
>   377onreply_route[MAIN] {
>   378# For fr_inv_timeout handling
>   379if (t_check_status("180")) {
>   380$var(180_in_trans)=1;
>   381route(test);
>   382xlog("back to MAIN reply route");
>   383}
>
> ERROR:sipmsgops:change_reply_status_f: the class of provisional or 
> positive final replies cannot be changed

I must note that change_reply_status works flawlessly when executing 
directly in MAIN reply route.


Thanks,

Malte

On 10/04/2026 01:03, Richard Robson wrote:

> No. Once in the reply_route you can call routes as a function. I think 
> that is what you are after.
>
> onreply_route{route_a]
>
> {stuff()..
>
> if x route(route_z)
> else route(_x)
>
> ..}
>
> route[route_z]
>
> {stuff()..
>
> ..}
>
>
> route[route_z]
>
> {stuff()..
>
> ..}
>
> Richard
>
>
> On 09/04/2026 10:13, spce at lard.at wrote:
>>
>> Hi,:
>>
>> thanks. In my case theres a quite big onreply route, which totally 
>> works, but is a hassle to read. Therefore I would like to segment 
>> some stuff into custom "functions", so I can have an easy to 
>> understand main onreply route and the more complicated logic in 
>> special blocks.
>>
>> A possibility for that would be to call secondary onreply routes from 
>> the parent route. Is that possible or not?
>>
>> Liebe Grüße / Kind regards,
>> Malte
>> On 08/04/2026 17.23, Richard Robson wrote:
>>> you call a reply route to handle the relpy. i.e. a positive outcome 
>>> 200OK or a 183 etc. This reply should be relayed back to the 
>>> originator and there should be no need to call another reply route. 
>>> it won't expect a reply just an ack and that should be handled as an 
>>> ACK and relayed or an error sent back. (see the default script)
>>> if you want the reply route to do something else then add a route to 
>>> do that or a branch route if needed. and call that from the reply 
>>> route (not nested)
>>>
>>> Richard
>>>
>>>
>>> On Wed, 2026-04-08 at 15:38 +0200, spce at lard.at wrote:
>>>> Hi,
>>>>
>>>> is it possible to use nested reply routes in opensips?
>>>>
>>>> I want to clean up my script and thinking of something like this:
>>>>
>>>> > onreply_route[MAIN] {
>>>> >  [...]
>>>> >  is_from_gw(1) = t_on_reply("ADD_ISUP");> }
>>>> >  [...] }
>>>> >  onreply_route[ADD_ISUP] {
>>>> >  add_isup_part() }
>>>>
>>>> The nested onreply route then should return to the parent onreply 
>>>> route. In my tests I specifically had issues with the rtpengine 
>>>> module: when using rtpengine_answer in the parent onreply route and 
>>>> then calling another onreply route from parent route, opensips 
>>>> wasn't able to see the SDP body in the reply and the 
>>>> rtpengine_answer thus failed.
>>>>
>>>>
>>>> -- 
>>>> Liebe Grüße / Kind regards,
>>>> Malte
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opensips.org
>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20260410/8143e5e9/attachment-0001.html>


More information about the Users mailing list