Hi Tihomir,<div>What do you mean by "took from Mera"? </div><div>If someone else already implemented this, could you please provide me a link?</div><div><br></div><div>This solution was invented by me personally, after looking into the following: <a href="http://wiki.freeswitch.org/wiki/SBC_Setup" target="_blank">http://wiki.freeswitch.org/wiki/SBC_Setup</a></div>
<div>They use <span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; ">Kamailio layer as routing, I decided that we can avoid this and use OOB things.</span></div><div><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;"><br>
</span></font></div><div><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">Thanks for your reply, it can add more value to the solution.</span></font></div><div><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;"><br>
</span></font></div><div><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">Regards,</span></font></div><div><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">vIT<br>
</span></font><br></div><div><br></div><div><br><div class="gmail_quote">2010/3/16 Tihomir Culjaga <span dir="ltr"><<a href="mailto:tculjaga@gmail.com">tculjaga@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
this is something you took from Mera .. isn't it ? :)<br><br><br><br><div class="gmail_quote"><div class="im">On Tue, Mar 16, 2010 at 1:04 PM, Vitalii Colosov <span dir="ltr"><<a href="mailto:vetali100@gmail.com" target="_blank">vetali100@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div>Hi dear FS community,</div><div><br></div><div>After a brief analysis of 2 solutions using OpenSIPS and <span style="font-family:sans-serif;font-size:13px;line-height:19px">Kamailio </span>(<a href="http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109" target="_blank">http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109</a> ) and (<a href="http://wiki.freeswitch.org/wiki/SBC_Setup" target="_blank">http://wiki.freeswitch.org/wiki/SBC_Setup</a>) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL).</div>
<div><br></div><div>It works on few of our servers right now without any issues.</div><div><br></div><div>Feel free to reuse / improve it or provide your comments if you see something wrong with it.</div><div><br></div><div>
<br></div><div>We have one routing server (RS) and several Media Servers (MS).</div><div>FreeSWITCH is installed on each server in default configuration.</div><div><br></div><div><span style="white-space:pre">        </span>--> MS_1</div>
<div>RS --> MS_2</div><div><span style="white-space:pre">        </span>--> MS_N</div><div><br></div><div><br></div><div>(Failover can be implemented by adding one more routing server, but this is out of scope of current description).</div>
</blockquote></div><div><br>routing server is your single point of failure, you should make two of them in active/standby mode. What about registered endpoints ? ... where do you register them?.... you should have a DB replication in order to have the "registered context" distributed between both routing servers<br>
<br><br>So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers.<br><br><br> </div><div class="im">
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div><br></div><div>Routing server routes calls to media servers based on logic that you can easily define.</div><div>(Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).</div>
<div><br></div></blockquote></div><div>you will be loosing calls on the on the MS if it goes down ... maybe there is a way to "replace" media resource for that calls and keep them going even after the MS went down.<br>
<br> </div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div></div><div><br></div><div>Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml).</div>
<div>Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).</div>
<div><br></div></blockquote></div><div><br>consider ODBC in the core!<br> <br></div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div></div><div>
<br></div><div>The whole routing can be presented by the following chain:</div><div><br></div><div>Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End</div>
<div><br></div><div>Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well).</div><div><br></div><div><u>1. RS Dialplan: default.xml</u></div>
<div><include></div><div> <extension name="route"></div><div> <condition field="destination_number" expression="^(00)(\d+)"></div><div> <action application="lua" data="route.lua $2"/></div>
<div> </condition></div><div> </extension> </div><div></include> </div><div><br></div><div><br></div><div><u>2. RS Lua script: route.lua</u></div><div>called_number = argv[1]; //without "00"</div>
<div>api = freeswitch.API();</div><div>server_ip_address = api:executeString("curl <a href="http://localhost/get_server_ip.php" target="_blank">http://localhost/get_server_ip.php</a>);</div><div>forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address;</div>
<div>session:setVariable("bypass_media", "true"); //described below!!!</div><div>session:execute("bridge",forwarding_session_string);</div><div><br></div></blockquote></div><div><br>do your bridging in the dialplan not from a script... you will get better performances!<br>
<br><br> </div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div></div><div><u>3. PHP script: get_server_ip.php</u></div>
<div><<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>></div><div>die($less_loaded_server_ip);</div><div><br></div><div><br></div><div>All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database).</div>
<div>If you use scripts you can update this table on starting a call and after call finished.</div><div>Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.</div><div><br>
</div><div><br></div><div>Basically that's all (really!)</div><div>I beleive it can be used for most general purpose scenarios without need of third-party tools.</div><div><br></div><div>P.S. </div><div>The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server.</div>
<div>But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free.</div><div>session:setVariable("bypass_media", "true");</div>
<div><br></div><div><br></div></blockquote></div><div><br>anyhow it is a good start ... with a custom module for media server "kepalive" and resource migration it could be a great solution.<br><br></div></div><br>
T.<br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>