<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">If you mean the effect, it did not stop FS although the results were the same, it prevented the fast FS shutdown/startup from activating the internal profile so <i>none</i> of the phone extensions work. In my case that meant all phones were out from 2am to whenever I activated internal. Not good in case of an emergency. Hope it may be useful to someone, it took me 15 days to find and resolve.<div><br></div><div>If you mean how is FreeSwitch shutdown, the 2am script runs a script that runs one command: <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">/usr/local/freeswitch/bin/fs_cli -x "shutdown"</span><div><br><div><div>On Apr 3, 2012, at 11:24 AM, Anthony Minessale wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>How exactly does it "stop" freeswitch?<br><br>On Tue, Apr 3, 2012 at 11:17 AM, Mario G <<a href="mailto:mario_fs@mgtech.com">mario_fs@mgtech.com</a>> wrote:<br><blockquote type="cite">I am posting this in case someone else runs into this, especially since I<br></blockquote><blockquote type="cite">found it may not be Mac OSX specific (I was able to duplicate on SUSE<br></blockquote><blockquote type="cite">although not as much).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Both of the following conditions must exist:<br></blockquote><blockquote type="cite">1. You have at least one TCP local extension. In this case, due to Bria,<br></blockquote><blockquote type="cite">etc. on an iPad, using TCP reduced battery usage since no need to run in<br></blockquote><blockquote type="cite">background.<br></blockquote><blockquote type="cite">2. FreeSwitch is recycled very quickly, in this case down/up within 30<br></blockquote><blockquote type="cite">seconds because it was automated at 2am each day. I needed it due to a long<br></blockquote><blockquote type="cite">running sofia memory leak on OSX which may be resolved but I need to test.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Problem: The extension using TCP cause a TIME_WAIT that keeps the 5060 port<br></blockquote><blockquote type="cite">active (but NOT open) on the TCP stack, in my case it was 30 seconds but I<br></blockquote><blockquote type="cite">found the time could be different on other platforms. When FreeSwitch comes<br></blockquote><blockquote type="cite">back up the "internal.xml" profile fails because port 5060 is in use. If FS<br></blockquote><blockquote type="cite">is brought up AFTER the TIME_WAIT goes away there is no problem, but in my<br></blockquote><blockquote type="cite">case it was very quick each night to minimize the outage.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Solution: I changed the OSX plist that auto restarts FS to run a script that<br></blockquote><blockquote type="cite">starts FS, this makes no difference except a script is more flexible. Rather<br></blockquote><blockquote type="cite">than use an arbitrary sleep time I check for port 5060 which is more<br></blockquote><blockquote type="cite">reliable and faster. I tested this many times using different scenarios and<br></blockquote><blockquote type="cite">all worked. Note I tried to use the "lsof -i TCP:5060" command but it shows<br></blockquote><blockquote type="cite">only OPEN ports so it won't work.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">#!/bin/sh<br></blockquote><blockquote type="cite">while : ; do<br></blockquote><blockquote type="cite"> a=$(/usr/sbin/netstat -p tcp)<br></blockquote><blockquote type="cite"> if [[ "$a" != *sip* ]] ; then<br></blockquote><blockquote type="cite"> break<br></blockquote><blockquote type="cite"> fi<br></blockquote><blockquote type="cite"> echo "Port 5060 still in use - waiting for it to free up"<br></blockquote><blockquote type="cite"> echo "${a}"<br></blockquote><blockquote type="cite"> /bin/sleep 3<br></blockquote><blockquote type="cite">done<br></blockquote><blockquote type="cite">/usr/local/freeswitch/bin/freeswitch -nc -nonat<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"># a=$(/usr/sbin/lsof -i TCP:5060) <- only shows open ports<br></blockquote><blockquote type="cite"># if [ "$a" = "" ] ; then<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Apr 3, 2012, at 8:53 AM, Mario G wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">For anyone who may run into this see "FS shutdown not closing TCP port<br></blockquote><blockquote type="cite">causes TIME_WAIT problems" for follow up and solution.<br></blockquote><blockquote type="cite">On Apr 2, 2012, at 1:33 PM, Mario G wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">That's what I was thinking, trying to figure out how now. Will post a<br></blockquote><blockquote type="cite">solution when I get one.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Apr 2, 2012, at 1:28 PM, Anthony Minessale wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">From what I see, sofia uses the REUSEADDR flag so I will bet its yet<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">another MAC specific thing.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I am not really sure what you can do since you tend to find issues<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">deep inside libsofia-sip and its portability to OSX.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Maybe make your restart script sleep a bit?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">su_setreuseaddr(socket, 1);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Mon, Apr 2, 2012 at 3:13 PM, Mario G <<a href="mailto:mario_fs@mgtech.com">mario_fs@mgtech.com</a>> wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If FS is shutdown and started too quickly, the internal profile ip/port<br></blockquote><blockquote type="cite">stays in use and FS will fail to start it. After searching on the wen I<br></blockquote><blockquote type="cite">found many references to TIME_WAIT but all fixes were to the program source.<br></blockquote><blockquote type="cite">So I am wondering if when FS/sofia shuts down they are not releasing the<br></blockquote><blockquote type="cite">ip/port for internal. If it's true, I found some source changes to solve it.<br></blockquote><blockquote type="cite">Google "TIME-WAIT" and you'll find lots of good stuff like<br></blockquote><blockquote type="cite"><a href="http://serverfault.com/questions/329845/how-to-forcibly-close-a-socket-in-time-wait">http://serverfault.com/questions/329845/how-to-forcibly-close-a-socket-in-time-wait</a>.<br></blockquote><blockquote type="cite">Apparently there is no way to free up the port manually. Help/comments<br></blockquote><blockquote type="cite">anyone?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Mario G<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_________________________________________________________________________</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br>MSN:anthony_minessale@hotmail.com<br>GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<br>IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>googletalk:conf+888@conference.freeswitch.org<br>pstn:+19193869900<br><br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br>consulting@freeswitch.org<br>http://www.freeswitchsolutions.com<br><br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>http://www.cudatel.com<br><br>Official FreeSWITCH Sites<br>http://www.freeswitch.org<br>http://wiki.freeswitch.org<br>http://www.cluecon.com<br><br>FreeSWITCH-users mailing list<br>FreeSWITCH-users@lists.freeswitch.org<br>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>http://www.freeswitch.org<br></div></blockquote></div><br></div></div></body></html>