No reINVITE when bridging two sessions from JavaScript with bypass_media_after_bridge=true
Dear colleagues, The task is to start two sessions from JS script and then bridge them in no-media mode. Unfirtunately, FreeSwitch does not reINVITE the peers after bridging. Here is my script: SCRIPT #1 - 'callback-session.js' <<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media_after_bridge=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{ignore_early_media=true}user/1001"); bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Then I run this script from the freeswitch console: freeswitch@internal> jsrun callback-session.js And there is no re-invites between peers, peers get connected and the traffic goes through FS BUT!!! Here is another scipt: SCRIPT #2 - 'callback-bridge.js' <<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media_after_bridge=true,continue_on_fail=true,ignore_early_media=true}user/1001"); session.execute("bridge","{ignore_early_media=false,originate_timeout=90}user/1001");
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
When I run this script, FreeSwitch successfuly sends reINVITES to both users after bridge, so they exchange media directly, not through FS. In my task, I need to have control when B-leg establishes (to start billing correctly), so I need to get the first scenario working. What I've already tried and did not succeed: 1) set bypass_media=true, on A leg only, on B leg only, on both legs 2) set bypass_media_after_bridge=true, on A leg only, on B leg only, on both legs Is there something I do wrong in the first script? What should I do to make FS reINVITE peers? Many thanks in advance! Best regards, Timur Valishev sip:tim@novion.ru
Dear colleagues, The task is to start two sessions from JS script and then bridge them in no-media mode. Unfirtunately, FreeSwitch does not reINVITE the peers after bridging. Here is my script: SCRIPT #1 - 'callback-session.js' <<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media_after_bridge=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{ignore_early_media=true}user/1001"); bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Then I run this script from the freeswitch console: freeswitch@internal> jsrun callback-session.js And there is no re-invites between peers, peers get connected and the traffic goes through FS BUT!!! Here is another scipt: SCRIPT #2 - 'callback-bridge.js' <<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media_after_bridge=true,continue_on_fail=true,ignore_early_media=true}user/1001"); session.execute("bridge","{ignore_early_media=false,originate_timeout=90}user/1001");
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
When I run this script, FreeSwitch successfuly sends reINVITES to both users after bridge, so they exchange media directly, not through FS. In my task, I need to have control when B-leg establishes (to start billing correctly), so I need to get the first scenario working. What I've already tried and did not succeed: 1) set bypass_media=true, on A leg only, on B leg only, on both legs 2) set bypass_media_after_bridge=true, on A leg only, on B leg only, on both legs Is there something I do wrong in the first script? What should I do to make FS reINVITE peers? Many thanks in advance! Best regards, Timur Valishev sip:tim@novion.ru
Dear colleagues, The task is to start two sessions from JS script and then bridge them in no-media mode. Unfirtunately, FreeSwitch does not reINVITE the peers after bridging. Here is my script: SCRIPT #1 - 'callback-session.js' <<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media_after_bridge=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{ignore_early_media=true}user/1001"); bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Then I run this script from the freeswitch console: freeswitch@internal> jsrun callback-session.js And there is no re-invites between peers, peers get connected and the traffic goes through FS. Is there something I do wrong in the script? What should I do to make FS reINVITE peers? Many thanks in advance! Best regards, Timur Valishev
http://wiki.freeswitch.org/wiki/Bypass_Media Also make sure you're on SVN trunk. /b On Feb 4, 2010, at 1:47 PM, Тимур Валишев wrote:
Is there something I do wrong in the first script? What should I do to make FS reINVITE peers? Many thanks in advance!
Thank you for reply, Brian! http://wiki.freeswitch.org/wiki/Bypass_Media says: *>Can I use bypass media when executing the bridge application from a javascript? * *>Of course you can, all it takes is setting the bypass_media session variable to true before the bridge: * *>session.setVariable('bypass_media', 'true'*); I've modified my script to make sure: <<<<<<<<<<<<<<<<<<<<<<<<<<<<, *session = new Session(* *"{ignore_early_media=true,hangup_after_bridge=true}sofia/external/ timwork@novion.ru"* *);* *session2 = new Session(* *"{ignore_early_media=true}sofia/external/timwork@novion.ru"* *);* *session.setVariable('bypass_media', 'true');* *session2.setVariable('bypass_media', 'true');* *bridge(session, session2);*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
But there is still no reINVITE =( SVN trunk I'm building from seems to be fresh: <<<<<<<<<<<<<<< *[root@sip freeswitch.trunk]# svn info* *Path: .* *URL: http://svn.freeswitch.org:/svn/freeswitch/trunk* *Repository Root: http://svn.freeswitch.org:/svn* *Repository UUID: d0543943-73ff-0310-b7d9-9358b9ac24b2* *Revision: 16561* *Node Kind: directory* *Schedule: normal* *Last Changed Author: mcollins* *Last Changed Rev: 16561* *Last Changed Date: 2010-02-03 04:53:31 +0300 (Wed, 03 Feb 2010)*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Do you have any ideas how to make FS reINVITE in this scenario? 2010/2/5 Brian West <brian@freeswitch.org>:
http://wiki.freeswitch.org/wiki/Bypass_Media
Also make sure you're on SVN trunk.
/b
On Feb 4, 2010, at 1:47 PM, Тимур Валишев wrote:
Is there something I do wrong in the first script? What should I do to make FS reINVITE peers? Many thanks in advance!
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
set it inside each of the {} for each session you create its not set after the fact the call is up already... you're setting it too late. you an also issue uuid_media off <uuid> /b On Feb 5, 2010, at 2:18 AM, Timur Valishev wrote:
I've modified my script to make sure: <<<<<<<<<<<<<<<<<<<<<<<<<<<<, session = new Session( "{ignore_early_media=true,hangup_after_bridge=true}sofia/external/timwork@novion.ru" ); session2 = new Session( "{ignore_early_media=true}sofia/external/timwork@novion.ru" ); session.setVariable('bypass_media', 'true'); session2.setVariable('bypass_media', 'true'); bridge(session, session2);
I think we are on the right way) still does not work, but there is hope) First of all, this script does not produce any reinvite either (even if replace bypass_media to bypass_media_after_bridge, or set bypass_media only on one channel): <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true} user/1001"); bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>
BUT! if I run the following script: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true} user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true}user/1001");
>>>>>>>>>>>>>>>>>>>>>>>
And then manually type in the console uuid_media off <uuid of my session> - then I get the reINVITE! BUT! When I try to write it to the script: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}sofia/external/ timwork@novion.ru"); session2 = new Session("{bypass_media=true,ignore_early_media=true}sofia/external/ timwork@novion.ru"); bridge(session, session2); apiExecute('uuid_media off '+session.uuid); // <-- this line is not executed, because bridge hangs up untill BYE
>>>>>>>>>>>>>>>>>>>>>>>
the last line is not executed, because bridge hangs up untill BYE Then I've tried to do like this: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true}user/1001"); session.setAutoHangup(false) session2.setAutoHangup(false) apiExecute("uuid_bridge "+session.uuid+" "+session2.uuid); apiExecute('uuid_media off '+session.uuid);
>>>>>>>>>>>>>>>>>>>>>>>
But sessions do not get bridged -( Even if I insert session.ready() after each call. Any ideas on how to call the functions correctly to get the reINVITE? Best regards, Timur Valishev 2010/2/5 Brian West <brian@freeswitch.org>
set it inside each of the {} for each session you create its not set after the fact the call is up already... you're setting it too late.
you an also issue uuid_media off <uuid>
/b
On Feb 5, 2010, at 2:18 AM, Timur Valishev wrote:
I've modified my script to make sure: <<<<<<<<<<<<<<<<<<<<<<<<<<<<, *session = new Session(* *"{ignore_early_media=true,hangup_after_bridge=true}sofia/external/ timwork@novion.ru"* *);* *session2 = new Session(* *"{ignore_early_media=true}sofia/external/timwork@novion.ru"* *);* *session.setVariable('bypass_media', 'true');* *session2.setVariable('bypass_media', 'true');* *bridge(session, session2);*
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
controlling multiple calls in a script like this is tricky, you need to use the first session to create the second one. Why are you not just doing an originate to do all of this not even in a js file? What exactly are you trying to accomplish Mike On Feb 5, 2010, at 3:02 PM, Timur Valishev wrote:
I think we are on the right way) still does not work, but there is hope)
First of all, this script does not produce any reinvite either (even if replace bypass_media to bypass_media_after_bridge, or set bypass_media only on one channel):
<<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true} user/1001"); bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>>
BUT! if I run the following script: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true} user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true}user/1001");
>>>>>>>>>>>>>>>>>>>>>>>>
And then manually type in the console uuid_media off <uuid of my session>
- then I get the reINVITE!
BUT! When I try to write it to the script: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}sofia/external/timwork@novion.ru"); session2 = new Session("{bypass_media=true,ignore_early_media=true}sofia/external/timwork@novion.ru"); bridge(session, session2); apiExecute('uuid_media off '+session.uuid); // <-- this line is not executed, because bridge hangs up untill BYE
>>>>>>>>>>>>>>>>>>>>>>>>
the last line is not executed, because bridge hangs up untill BYE
Then I've tried to do like this: <<<<<<<<<<<<<<<<<<<<<<<<<<<<< session = new Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001"); session2 = new Session("{bypass_media=true,ignore_early_media=true}user/1001");
session.setAutoHangup(false) session2.setAutoHangup(false)
apiExecute("uuid_bridge "+session.uuid+" "+session2.uuid); apiExecute('uuid_media off '+session.uuid);
>>>>>>>>>>>>>>>>>>>>>>>>
But sessions do not get bridged -( Even if I insert session.ready() after each call.
Any ideas on how to call the functions correctly to get the reINVITE?
Best regards, Timur Valishev
2010/2/5 Brian West <brian@freeswitch.org> set it inside each of the {} for each session you create its not set after the fact the call is up already... you're setting it too late.
you an also issue uuid_media off <uuid>
/b
On Feb 5, 2010, at 2:18 AM, Timur Valishev wrote:
I've modified my script to make sure: <<<<<<<<<<<<<<<<<<<<<<<<<<<<, session = new Session( "{ignore_early_media=true,hangup_after_bridge=true}sofia/external/timwork@novion.ru" ); session2 = new Session( "{ignore_early_media=true}sofia/external/timwork@novion.ru" ); session.setVariable('bypass_media', 'true'); session2.setVariable('bypass_media', 'true'); bridge(session, session2);
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Dear Mike,
I'm trying to build a kind of complicated callback. I will be happy if
you suggest alternative way to do it!
Scenario is:
0. Get command over the socket to initiate connection, get A-number,
B-number, route preference, Caller ID option (incognito/normal)
1. Call billing stored procedure to determine maximum call duration
2. Reply over the socket (or better through database?) that connection
is in progrees (to display it on the user GUI)
3. Initiate connection to A-number
4. Upon connection to A, say welcome, start calling B, play ringback tone
5. Upon dialling B, call billing stored procedure to report that
session state changed and report the status to user GUI (over the
socket or through the database?)
5.1 If there was error during connection - speak the reason to end
user (e.g. "Number busy" or "Timeout expired" etc.)
6. Join peers in bypass media mode
6.1 Wait for various commands over the socket - e.g. transfer the
call, put on hold, join to conference etc. User will have GUI for that
operations.
7. If B hangs up, call billing stored procedure to finalize session
and calculate the cost of the call. Cost is to be calculated only by
B-leg length. Speak to A the cost of the call, say thanks and hang up.
7.1 If A hangs up, just call billing and terminate.
Best regards,
Timur Valishev
2010/2/10 Michael Jerris <mike@jerris.com>:
> controlling multiple calls in a script like this is tricky, you need to use
> the first session to create the second one. Why are you not just doing an
> originate to do all of this not even in a js file? What exactly are you
> trying to accomplish
> Mike
> On Feb 5, 2010, at 3:02 PM, Timur Valishev wrote:
>
> I think we are on the right way) still does not work, but there is hope)
> First of all, this script does not produce any reinvite either (even if
> replace bypass_media to bypass_media_after_bridge, or set bypass_media only
> on one channel):
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> session = new
> Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001");
> session2 = new
> Session("{bypass_media=true,ignore_early_media=true} user/1001");
> bridge(session, session2);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> BUT! if I run the following script:
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> session = new
> Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true} user/1001");
> session2 = new
> Session("{bypass_media=true,ignore_early_media=true}user/1001");
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> And then manually type in the console
> uuid_media off <uuid of my session>
> - then I get the reINVITE!
> BUT! When I try to write it to the script:
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> session = new
> Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}sofia/external/timwork@novion.ru");
> session2 = new
> Session("{bypass_media=true,ignore_early_media=true}sofia/external/timwork@novion.ru");
> bridge(session, session2);
> apiExecute('uuid_media off '+session.uuid); // <-- this line is not
> executed, because bridge hangs up untill BYE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> the last line is not executed, because bridge hangs up untill BYE
> Then I've tried to do like this:
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> session = new
> Session("{bypass_media=true,ignore_early_media=true,hangup_after_bridge=true}user/1001");
> session2 = new
> Session("{bypass_media=true,ignore_early_media=true}user/1001");
> session.setAutoHangup(false)
> session2.setAutoHangup(false)
> apiExecute("uuid_bridge "+session.uuid+" "+session2.uuid);
> apiExecute('uuid_media off '+session.uuid);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> But sessions do not get bridged -( Even if I insert session.ready() after
> each call.
> Any ideas on how to call the functions correctly to get the reINVITE?
> Best regards,
> Timur Valishev
> 2010/2/5 Brian West <brian@freeswitch.org>
>>
>> set it inside each of the {} for each session you create its not set after
>> the fact the call is up already... you're setting it too late.
>> you an also issue uuid_media off <uuid>
>> /b
>> On Feb 5, 2010, at 2:18 AM, Timur Valishev wrote:
>>
>> I've modified my script to make sure: <<<<<<<<<<<<<<<<<<<<<<<<<<<<,
>> session = new Session(
>>
>> "{ignore_early_media=true,hangup_after_bridge=true}sofia/external/timwork@novion.ru"
>> );
>> session2 = new Session(
>> "{ignore_early_media=true}sofia/external/timwork@novion.ru"
>> );
>> session.setVariable('bypass_media', 'true');
>> session2.setVariable('bypass_media', 'true');
>> bridge(session, session2);
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users@lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users@lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users@lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
I would suggest using scripts in between the bridge attempts when you need to do logic, but to do most of this in dialplan where you can. so through 3, you can handle however you were, then drip A back to dialplan to bridge the call (continue_on_fail, hangup_after_bridge=false), then after bridge, call another script if you need to do more advanced logic. On Feb 10, 2010, at 3:35 AM, Timur Valishev wrote:
Dear Mike,
I'm trying to build a kind of complicated callback. I will be happy if you suggest alternative way to do it!
Scenario is:
0. Get command over the socket to initiate connection, get A-number, B-number, route preference, Caller ID option (incognito/normal) 1. Call billing stored procedure to determine maximum call duration 2. Reply over the socket (or better through database?) that connection is in progrees (to display it on the user GUI) 3. Initiate connection to A-number 4. Upon connection to A, say welcome, start calling B, play ringback tone 5. Upon dialling B, call billing stored procedure to report that session state changed and report the status to user GUI (over the socket or through the database?) 5.1 If there was error during connection - speak the reason to end user (e.g. "Number busy" or "Timeout expired" etc.) 6. Join peers in bypass media mode 6.1 Wait for various commands over the socket - e.g. transfer the call, put on hold, join to conference etc. User will have GUI for that operations. 7. If B hangs up, call billing stored procedure to finalize session and calculate the cost of the call. Cost is to be calculated only by B-leg length. Speak to A the cost of the call, say thanks and hang up. 7.1 If A hangs up, just call billing and terminate.
Best regards, Timur Valishev
2010/2/10 Michael Jerris <mike@jerris.com>:
controlling multiple calls in a script like this is tricky, you need to use the first session to create the second one. Why are you not just doing an originate to do all of this not even in a js file? What exactly are you trying to accomplish Mike
participants (4)
-
Brian West
-
Michael Jerris
-
Timur Valishev
-
Тимур Валишев