<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><font class="Apple-style-span" face="arial" size="4"><span class="Apple-style-span" style="font-size: 10pt;">hi Michael,</span></font><div style="font-family: arial; font-size: 10pt; ">Thank you for your input. Really appreciate when having someone giving help when in need.</div><div style="font-family: arial; font-size: 10pt; ">I bought FS ebook, read chapter 9 and 10. And did what you said:</div><div style="font-family: arial; font-size: 10pt; ">1- put the event_socket_conf.xml back to original state, just modify the ip address, because I work through a vpn network. Here , could you confirm that mod_event_socket supports different browsers ? This is really important to me, because if client could not access from www, there is no point to work on this. Thank you.</div><div style="font-family: arial; font-size: 10pt; ">-------- the
event_socket_conf.xml</div><div style="font-family: arial; font-size: 10pt; "><div><configuration name="event_socket.conf" description="Socket Client"></div><div> <settings></div><div> <param name="nat-map" value="false"/></div><div> <param name="listen-ip" value="192.168.51.133"/></div><div> <param name="listen-port" value="8021"/></div><div> <param name="password" value="ClueCon"/></div><div> <!--param name="apply-inbound-acl" value="lan"/--></div><div> </settings></div><div></configuration></div></div><div style="font-family: arial; font-size: 10pt; ">-----------</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">2- I put this in both dialplan/default.xml and dialplan/public.xml </div><div style="font-family:
arial; font-size: 10pt; ">------------</div><div style="font-family: arial; font-size: 10pt; "><div><extension name="outbound-socket"></div><div><span class="Apple-tab-span" style="white-space:pre">                </span><condition field="destination_number" expression="^444$"></div><div><span class="Apple-tab-span" style="white-space:pre">                </span><action application="socket" data="192.168.51.133:8021 async full"/></div><div><span class="Apple-tab-span" style="white-space:pre">                </span></condition></div><div></extension></div></div><div style="font-family: arial; font-size: 10pt; ">------------</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">3- I have a simple php script just to connect to the FS, this is a sample script from FS wiki page</div><div style="font-family: arial; font-size: 10pt; ">------</div><div><div><font class="Apple-style-span" face="arial"
size="3"><span class="Apple-style-span" style="font-size: 13px;"><?php</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">//require_once('ESL.php');</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">require_once('/usr/src/freeswitch/freeswitch-snapshot/libs/esl/php/ESL.php');</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">set_time_limit(0); // Remove the PHP time limit of 30 seconds for completion due to loop watching events</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">echo
"HERE";</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">// Connect to FreeSWITCH</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">$sock = new ESLconnection('localhost', '8021', 'ClueCon');</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">// We want all Events (probably will want to change this depending on your needs)</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">$sock->sendRecv("event plain ALL");</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span
class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">// Grab Events until process is killed</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">//while($sock->connected()){</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">//echo "CONECTED";</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">//$event = $sock->recvEvent();</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">//print_r($event->serialize());</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span
class="Apple-style-span" style="font-size: 13px;">//}</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">?></span></font></div></div><div style="font-family: arial; font-size: 10pt; ">------</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">when running this from web browser, I got blank page. So, I run from console, this is the error messages:</div><div style="font-family: arial; font-size: 10pt; ">--------</div><div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP Warning: dl(): Unable to load dynamic library '/usr/lib/php/modules/ESL.so' - /usr/lib/php/modules/ESL.so: cannot open shared
object file: No such file or directory in /usr/src/freeswitch/freeswitch-snapshot/libs/esl/php/ESL.php on line 23</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP Stack trace:</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP 1. {main}() /var/www/html/eventsocket.php:0</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP 2. require_once() /var/www/html/eventsocket.php:4</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP 3. dl() /usr/src/freeswitch/freeswitch-snapshot/libs/esl/php/ESL.php:23</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span
class="Apple-style-span" style="font-size: 13px;">HEREPHP Fatal error: Call to undefined function new_ESLconnection() in /usr/src/freeswitch/freeswitch-snapshot/libs/esl/php/ESL.php on line 119</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP Stack trace:</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP 1. {main}() /var/www/html/eventsocket.php:0</span></font></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 13px;">PHP 2. ESLconnection->__construct() /var/www/html/eventsocket.php:8</span></font></div></div><div style="font-family: arial; font-size: 10pt; ">----------</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">So, I guess
the ESL.so is missing. I tried to "locate ESL.so" , but nothing returned. I tried to </div><div style="font-family: arial; font-size: 10pt; ">--------</div><div style="font-family: arial; font-size: 10pt; "><span class="Apple-style-span" style="font-family: sans-serif; line-height: 19px; "><pre style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; ">yum install libxml2-devel pcre-devel bzip2-devel curl-devel gmp-devel aspell-devel php-devel libtermcap-devel gdbm-devel
db4-devel</pre></span></div><div style="font-family: arial; font-size: 10pt; ">--------</div><div style="font-family: arial; font-size: 10pt; ">it ran fine. But I did not do this:</div><div style="font-family: arial; font-size: 10pt; ">-------</div><div style="font-family: arial; font-size: 10pt; "><span class="Apple-style-span" style="font-family: sans-serif; line-height: 19px; "><b>NOTE:</b> For PHP you must edit the libs/esl/php/Makefile and add -lpthread to the LOCAL_LDFLAGS line.</span></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">-------</span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">because I could not fine the LOCAL_LDFLAGS line.</span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span
class="Apple-style-span" style="line-height: 19px;"><br></span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">Please give me some help, I am banging my head against the wall here. If I could get the file ESL.so , is the set up above working? I thought it would be simple just to connect.</span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;"><br></span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;">Thank you.</span></font></div><div style="font-size: 10pt; "><font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 19px;"><br></span></font><font class="Apple-style-span" face="arial">--- On </font><b
style="font-family: arial; ">Thu, 10/28/10, Michael Collins <i><msc@freeswitch.org></i></b><font class="Apple-style-span" face="arial"> wrote:</font><br><blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-family: arial; "><br>From: Michael Collins <msc@freeswitch.org><br>Subject: Re: [Freeswitch-users] Mod Event Socket<br>To: "FreeSWITCH Users Help" <freeswitch-users@lists.freeswitch.org><br>Received: Thursday, October 28, 2010, 5:57 PM<br><br><div id="yiv878749678">Be sure to learn the difference between inbound and outbound event socket. In your case you are doing outbound event socket. The dialplan calls the socket app which does an outbound socket connection to port 9090 on the localhost. Make sure that your app is listening on port 9090.<br>
<br>The event_socket.conf.xml file is for configuring inbound socket connections, e.g. when you have a script that attempts to connect to FS where FS is listening on port 8021. So change your event_socket.conf.xml file back to the default and retry. <br>
<br>Report back here if you have trouble. Also, buy or borrow the FreeSWITCH book and check out chapter 9. Lots of good stuff there on how the even system works.<br><br>-MC<br><br><div class="yiv878749678gmail_quote">On Thu, Oct 28, 2010 at 2:14 PM, Will Smith <span dir="ltr"><<a rel="nofollow" ymailto="mailto:willbelair@yahoo.com" target="_blank" href="/mc/compose?to=willbelair@yahoo.com">willbelair@yahoo.com</a>></span> wrote:<br>
<blockquote class="yiv878749678gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit;" valign="top">Hi,<div>I am new to FS, and trying to get the mod event socket installed and running. I have FS running, with SIP account, can dial in/out via gateway.</div>
<div>Now I want to dial in, FS will send some info to client browser, here is one question, does this work over the internet, or just local ? Info sent could be the uuid, so that client browser could decide to bridge the call, send to IVR or transfer ...</div>
<div>Please give me some guide line how to set this up.</div><div>I added to dialplan/default.xml</div><div>-----</div><div><span style="font-size:medium;"><pre> <extension name="socketTest">
<condition field="destination_number" expression="^444$">
<action application="socket" data="<a rel="nofollow" target="_blank" href="http://127.0.0.1:9090">127.0.0.1:9090</a> async full"/>
</condition>
</extension></pre><pre>-----</pre><pre><br></pre><pre>got the php sample file: </pre><pre><span style="white-space:normal;"><pre style="word-wrap:break-word;white-space:pre-wrap;"><?php
/**
* Based loosely on the NET_Server code in PEAR.
* This is only an example - considerable additional work is needed
* Specifically, the code in the handleConnection method should be
* handled in a subclass
*
*
*/
class Message
{
var $properties = array();
var $content = null;
}
class EventSocketListener
{
var $host;
var $port;
var $sock;
var $is_parent = true;
var $clientInfo;
var $clientFD;
var $connectionContext = array();
function &create($port, $host = "localhost")
{
        $esl = new EventSocketListener;
        $esl->port = $port;
        $esl->host = $host;
if (!function_exists('socket_create')) {
return PEAR::raiseError('Sockets extension not available.');
}
        return $esl;
}
function start()
{
        if (($this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
         echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
        }
        if (!socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 1)) {
         echo 'Unable to set option on socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
        }
        if (socket_bind($this->sock, $this->host, $this->port) === false) {
         echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($this->sock)) . "\n";
        }
        if (socket_listen($this->sock, 5) === false) {
         echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($this->sock)) . "\n";
        }
// Dear children, please do not become zombies
pcntl_signal(SIGCHLD, SIG_IGN);
// wait for incmoning connections
while (true)
{
// new connection
if(($fd = socket_accept($this->sock)))
{
         $pid = pcntl_fork();
         if($pid == -1) {
                 return PEAR::raiseError('Could not fork child process.');
}
// This is the child => handle the request
elseif($pid == 0) {
// this is not the parent
$this->_isParent = false;
// store the new file descriptor
$this->clientFD = $fd;
$peer_host = "";
$peer_port = "";
socket_getpeername($this->clientFD, $peer_host, $peer_port);
$this->clientInfo = array(
"host" => $peer_host,
"port" => $peer_port,
"connectOn" => time()
);
                 $this->handleConnection();
                 socket_shutdown($this->clientFD, 2);
                 socket_close($this->clientFD);
                }
                else /* Parent does nothing */
                 {
                 }
         }
        }
}
function handleConnection()
{
$fd = $this->clientFD;
//first, read headers & setup a state for this connection
$line = "";
socket_write($fd, "CONNECT\n\n");
do
{
        $line = socket_read($fd, 2048, PHP_NORMAL_READ);
        if (trim($line) == "")
         break;
        //we got a header, we need to add it to the
        list($key, $value) = explode(":", $line);
        $key = trim($key);
        $value = trim(urldecode($value));
        $this->connectionContext[$key] = $value;
}
while ($line != "");
// print_r($this->connectionContext);
$this->callConnected();
exit();
}
function processMessages($returnOnReply = false)
{
$fd = $this->clientFD;
$result = new Message();
$props = array();
while (true)
{
        do
         {
         $line = @socket_read($fd, 2048, PHP_NORMAL_READ);
         if (socket_last_error($fd) == 104)
         return null;
         if ($line == null || $line == FALSE || trim($line) == "")
         break;
         //we got a header, we need to add it to the message
         list($key, $value) = explode(":", $line);
         $key = trim($key);
         $value = trim(urldecode($value));
         $props[$key] = $value;
         }
        while ($line != "");
        $result->properties = $props;
        if (isset($props['Content-Length']))
         {
         $length = $props['Content-Length'];
         print("Reading content - $length\n");
         $data = socket_read($fd, $length);
         $result->content = $data;
         }
        if (isset($props['Content-Type']))
         {
         $type = $props['Content-Type'];
         if ($returnOnReply &&
                ($type == "command/reply" || $type == "api/response"))
         {
                return $result;
         }
         else if ($type == "text/event-plain") //only plain events for now
         {
                $this->handleEvent($result);
         }
         }
        else
         {
         print("UNKNOWN MESSAGE: \n");
         print_r($result);
         }
}
}
function invokeCommand($command)
{
//Send the command
print("Invoking: $command\n");
$this->sendCommand($command);
// Wait for the response
$result = $this->processMessages(true);
return $result;
}
function sendCommand($command)
{
$fd = $this->clientFD;
socket_write($fd, trim($command) . "\n\n");
}
/*-----------------------------------------------------*/
/* Abstract Methods - should move to subclass*/
function callConnected()
{
print_r($this->connectionContext);
print("----------------\n");
$result = $this->invokeCommand("log DEBUG");
print_r($result);
$result = $this->invokeCommand("event plain ALL");
print_r($result);
$this->processMessages(false);
print("DONE PROCESSING MESSAGES");
print_r($this->connectionContext);
}
function handleCommandResponse($response)
{
print("Recieved Unhandled Response:\n");
print_r($response);
}
function handleEvent($event)
{
print("Recieved Unhandled Event:\n");
print_r($event);
}
}
// create a server that forks new processes
$server = &EventSocketListener::create(9090);
// start the server
$server->start();
?></pre><pre style="word-wrap:break-word;white-space:pre-wrap;">--------</pre><pre style="word-wrap:break-word;white-space:pre-wrap;">( this is the original file, not perfect sample) I tried to run this, and got error with auth.</pre>
<pre style="word-wrap:break-word;white-space:pre-wrap;">Also, I modify the even_socket_conf.xml in autoload_configs/ </pre><pre style="word-wrap:break-word;white-space:pre-wrap;">change listen-ip to 0.0.0.0 , port = 9090 , disable password</pre>
<pre style="word-wrap:break-word;white-space:pre-wrap;"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap;">What did I miss? </pre><pre style="word-wrap:break-word;white-space:pre-wrap;">Thankyou for your help</pre>
<pre style="word-wrap:break-word;white-space:pre-wrap;">Will</pre><pre style="word-wrap:break-word;white-space:pre-wrap;"><br></pre></span></pre></span></div></td></tr></tbody></table><br><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a rel="nofollow" ymailto="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank" href="/mc/compose?to=FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a rel="nofollow" target="_blank" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a rel="nofollow" target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a rel="nofollow" target="_blank" href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>FreeSWITCH-users mailing list<br><a ymailto="mailto:FreeSWITCH-users@lists.freeswitch.org" href="/mc/compose?to=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></div></blockquote></div></td></tr></table><br>