signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.32k stars 1.38k forks source link

When using bypass_media_after_bridge, <sip_invite_route_uris> in database are in reverse order for inbound call #2443

Open harweyh opened 2 months ago

harweyh commented 2 months ago

When bypass_media_after_bridge option is used, call recovery fails because inbound call routes are in reverse order and FS is trying to send re-INVITE to wrong host (that it can't resolve which can be seen in debug logs).

I have dialplan which plays message to user and after that bridges call. When call is connected, FS removes itself from media path by using bypass_media_after_bridge.

After this i simulate FS crash and when calls are recovered, SIP re-invite is sent only to outbound call but not for inbound. When i investigated recovery data in database (MariaDB), I noticed that parameters are in reverse order for inbound call. I can see from debug logs that FS was failing when it tried to resolve that first route (and that is expected as that route should be last and it is not resolvable on host where FS is running).

This happens only when I am using this bypass_media_after_bridge functionality. If I don't use it, all routes are in correct order and everything works as expected when call recovery happens.

Freeswitch version that I'm using is 1.10.11.

I also wrote python script which is reversing addresses (to make them correct order) before crashing and executing sofia recover command and in that scenario everything seems to work correctly, so it looks like that something is causing those routes to reverse when SIP re-INVITEs to bypass media happens.

To reproduce:

Use dialplan with , crash FS and recover calls.

<extension name="servicetest">
    <condition field="destination_number" expression="^\+12345567$">
        <action application="ring_ready"/>
        <action application="pre_answer"/>
        <action application="sleep" data="1500"/>
        <action application="playback" data="/usr/local/freeswitch/audio/message.wav"/>
        <action application="set" data="ringback=${fin-ring}"/>
        <action application="set" data="hangup_after_bridge=true"/>
        <action application="set" data="bypass_media_after_bridge=true"/>
        <action application="bridge" data="sofia/gateway/kamailio/+7654321"/>
    </condition>
</extension>

Expected behavior: Freeswitch should send SIP re-INVITEs correctly