How to bridge 2 sessions with Javascript?
Hello everybody again, First of all I want to say thanks to the people on this list and on IRC, I'm really surprised (in a very good way) of the help I've received. Now to my problem: I'm trying to bridge two SIP calls together with a JS script, and to achieve it, I'm did the following: - created a dialplan entry for extension 500 which calls js script - created a js script with the following code: // Create new_session session1 = new Session(); session1.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/005624949458"); session1.waitForAnswer(10000); new_session = new Session(); new_session.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/0056979039388", 30); new_session.waitForAnswer(10000); // IF everybody is ready, then bridge our current session & the new_session if (session1.ready() && new_session.ready()) { console_log("info", "Interoligofrenico!\n"); bridge(session1, new_session); } // hangup when done session1.hangup(); new_session.hangup(); When I register with extension 1000 using a softphone and dial extension 500, the code above successfully creates the two new sessions, makes the calls in order, and supposedly bridges the sessions (I get no error about the bridge on the console, and I get the log text too), but I get no audio on either end. Anybody know what's wrong with the code? Btw, how can I originate a call to a configure extension? All examples on the wiki use the 'sofia syntax', should I just use sofia/default/1001 for example? Thanks! Nicolas
If you change this one line:
if (session1.ready() && new_session.ready()) {
session1 = new Session(); session1.originate(session, "{ignore_early_media=true}sofia/gateway/ asterlink.com/19184249378"); new_session = new Session(); new_session.originate(session, "{ignore_early_media=true}sofia/gateway/ asterlink.com/19184238080"); bridge(session1, new_session ); // this line is key. while (session1.ready() && new_session.ready()) { // do nothing } This also means the first leg calling 500 will be up till the call ends.. this is not the most optimal way of doing it.... It also means you can't hangup the first leg till you're 100% sure the third leg is up or all legs will hang up and the call will fail. You might want to learn about jsrun. For example if you take that script above and do "jsrun script.js" it'll perform the same thing without the extra leg. /b On Mar 27, 2008, at 9:10 PM, Nicolas Brenner wrote:
Hello everybody again,
First of all I want to say thanks to the people on this list and on IRC, I'm really surprised (in a very good way) of the help I've received.
Now to my problem: I'm trying to bridge two SIP calls together with a JS script, and to achieve it, I'm did the following: - created a dialplan entry for extension 500 which calls js script - created a js script with the following code:
// Create new_session session1 = new Session(); session1.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/ 005624949458"); session1.waitForAnswer(10000);
new_session = new Session(); new_session.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/ 0056979039388", 30); new_session.waitForAnswer(10000);
// IF everybody is ready, then bridge our current session & the new_session if (session1.ready() && new_session.ready()) { console_log("info", "Interoligofrenico!\n"); bridge(session1, new_session); }
// hangup when done session1.hangup(); new_session.hangup();
When I register with extension 1000 using a softphone and dial extension 500, the code above successfully creates the two new sessions, makes the calls in order, and supposedly bridges the sessions (I get no error about the bridge on the console, and I get the log text too), but I get no audio on either end. Anybody know what's wrong with the code?
Btw, how can I originate a call to a configure extension? All examples on the wiki use the 'sofia syntax', should I just use sofia/default/1001 for example?
Thanks!
Nicolas
_______________________________________________ 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
Revised script: session1 = new Session(); session1.originate(session1, "{ignore_early_media=true}sofia/gateway/ asterlink.com/19184249378"); session2 = new Session(); session2.originate(session2, "sofia/gateway/asterlink.com/19184238080"); bridge(session1, session2); session.hangup(); while (session1.ready() && session2.ready()) { } You don't need waitForAnswer because the ignore_early_media=true performs that automatically for you so it won't return till you answer. And you don't want the ignore_early_media on the second leg otherwise you get NO ringback and its just silent till the other end is answered. /b On Mar 27, 2008, at 9:10 PM, Nicolas Brenner wrote:
Hello everybody again,
First of all I want to say thanks to the people on this list and on IRC, I'm really surprised (in a very good way) of the help I've received.
Now to my problem: I'm trying to bridge two SIP calls together with a JS script, and to achieve it, I'm did the following: - created a dialplan entry for extension 500 which calls js script - created a js script with the following code:
// Create new_session session1 = new Session(); session1.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/ 005624949458"); session1.waitForAnswer(10000);
new_session = new Session(); new_session.originate(session, "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/ 0056979039388", 30); new_session.waitForAnswer(10000);
// IF everybody is ready, then bridge our current session & the new_session if (session1.ready() && new_session.ready()) { console_log("info", "Interoligofrenico!\n"); bridge(session1, new_session); }
// hangup when done session1.hangup(); new_session.hangup();
When I register with extension 1000 using a softphone and dial extension 500, the code above successfully creates the two new sessions, makes the calls in order, and supposedly bridges the sessions (I get no error about the bridge on the console, and I get the log text too), but I get no audio on either end. Anybody know what's wrong with the code?
Btw, how can I originate a call to a configure extension? All examples on the wiki use the 'sofia syntax', should I just use sofia/default/1001 for example?
Thanks!
Nicolas
_______________________________________________ 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
Thanks! It worked as advertised. The only problem I have now, is my provider (I'm trying gafachi now), I'm getting about one or two seconds delay on the audio, which is pretty bad. One other thing, it takes about 5 or 10 seconds to get a ring tone after answering the first call, is there anyway to fake the tone in the meantine, or just plainly "replace" the tone until the call is answered? Thanks again! Nicolas
I had some slow connection problems with sipphone that were solved by: <param name="bind-params" value="transport=udp"/> in the sip profile, might be worth a go. BTW this is a bug with sipphone, not with Freeswitch. - Dale ------------------------------------------------ http://myhelpa.com - Sign up to be a Beta Helpa. On Fri, 2008-03-28 at 08:46 -0400, Nicolas Brenner wrote:
Thanks! It worked as advertised.
The only problem I have now, is my provider (I'm trying gafachi now), I'm getting about one or two seconds delay on the audio, which is pretty bad.
One other thing, it takes about 5 or 10 seconds to get a ring tone after answering the first call, is there anyway to fake the tone in the meantine, or just plainly "replace" the tone until the call is answered?
Thanks again!
Nicolas
_______________________________________________ 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
Dale, This was due to a rogue SRV record saying use TCP that has since been corrected after a month of talking to them about it. /b On Mar 28, 2008, at 8:50 AM, Dale Thatcher wrote:
I had some slow connection problems with sipphone that were solved by:
<param name="bind-params" value="transport=udp"/>
in the sip profile, might be worth a go. BTW this is a bug with sipphone, not with Freeswitch.
- Dale
Great, guess I'll drop that from my config then. Sorry Nicolas must be something else. - Dale On Fri, 2008-03-28 at 09:53 -0500, Brian West wrote:
Dale, This was due to a rogue SRV record saying use TCP that has since been corrected after a month of talking to them about it.
/b
On Mar 28, 2008, at 8:50 AM, Dale Thatcher wrote:
I had some slow connection problems with sipphone that were solved by:
<param name="bind-params" value="transport=udp"/>
in the sip profile, might be worth a go. BTW this is a bug with sipphone, not with Freeswitch.
- Dale
_______________________________________________ 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
http://myhelpa.com - Sign up to be a Beta Helpa.
participants (3)
-
Brian West
-
Dale Thatcher
-
Nicolas Brenner