<html><body bgcolor="#FFFFFF"><div>Your using outbound socket and you hangup the call, so it tells you it is done with the server disconnected message and drops the connection. This is all as expected. I guess I don't understand what you think is the problem. This code is doing exactly what I would expect it to do.</div><div><br></div><div>Mike</div><div><br>On Nov 26, 2009, at 4:27 AM, lakshmanan ganapathy <<a href="mailto:lakindia89@gmail.com">lakindia89@gmail.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>Hi, Any help or suggestion regarding my previous post. Especially<br><br>"I also noted that, if I don't receive any events, especially "SERVER_DISCONNECTED", then the connection is in established state, but
once I receive the "SERVER_DISCONNECTED" event, the connection is
closed. Is it correct??"<br>Here is the program by which I confirmed the above!<br><br>require ESL;<br>use IO::Socket::INET;<br><br>my $ip = "192.168.1.222";<br>my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8447', Proto => 'tcp', Listen => 2, Reuse => 1 );<br>
die "Could not create socket: $!\n" unless $sock;<br>my $con;<br>my $type = "user/";<br><br>for(;;) {<br> # wait for any client to connect, a new client will get connected when a new call comes in the dialplan.<br>
my $new_sock = $sock->accept();<br> # Do fork and let the parent to wait for more clients.<br> my $pid = fork();<br> if ($pid) {<br> close($new_sock);<br> next;<br>
}<br> # Extract the host of the client.<br> my $host = $new_sock->sockhost();<br> # file descriptor for the socket.<br> my $fd = fileno($new_sock);<br> print "Host name is $host\n";<br>
# Create object for the ESL connection package to access the ESL functions.<br> $con = new ESL::ESLconnection($fd);<br> # Gets the info about this channel.<br> my $info = $con->getInfo();<br>
my $uuid = $info->getHeader("unique-id");<br> printf "Connected call %s, from %s to %s\n", $uuid, $info->getHeader("caller-caller-id-number"), $info->getHeader("caller-destination-number");<br>
<br> # Answer the channel.<br> $con->execute("answer");<br> # Set the event lock to tell the FS to execute the instructions in the given order.<br> $con->setEventLock("true");<br>
# Play a file & Get the personal number from the user.<br> $con->execute("playback","/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");<br> $con->execute("hangup");<br>
while($con->connected())<br> {<br> my $e=$con->recvEvent();<br> my $ename=$e->getHeader("Event-Name");<br> print $e->serialize();<br> print "$ename\n";<br>
print "Connection exists\n";<br> sleep(1);<br> }<br> print "Bye\n------------------------------------------------------------------\n";<br> close($new_sock);<br>
}<br> I've not registered for any events.<br> In the above program I'm receiving the SERVER_DISCONNECTED event.<br>Output when receiving event:<br> Host name is 192.168.1.222<br> Connected call 022b79f8-d8c0-11de-8d50-596fac84e59e, from 1000 to 9097<br>
Event-Name: SERVER_DISCONNECTED<br><br> SERVER_DISCONNECTED<br> Connection exists<br> Bye<br><br>When I comment the recvEvent line, I got the following output.<br><br> Host name is 192.168.1.222<br> Connected call 65b7f64a-d8c0-11de-8d50-596fac84e59e, from 1000 to 9097<br>
Connection exists<br> Connection exists<br> Connection exists<br> Connection exists<br> Connection exists<br><br><br><div class="gmail_quote">On Tue, Nov 24, 2009 at 5:57 PM, lakshmanan ganapathy <span dir="ltr"><<a href="mailto:lakindia89@gmail.com"><a href="mailto:lakindia89@gmail.com">lakindia89@gmail.com</a></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;">I've tried the following program as per the suggestion that you've told. But it seems, no success. Once the connection is closed, I created a new connection and I send originate to originate a new call. But it is not working.<br>
<br>require ESL;<br>use IO::Socket::INET;<br>use Data::Dumper;<br><br>my $ip = "192.168.1.222";<br>my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8447', Proto => 'tcp', Listen => 2, Reuse => 1 );<br>
die "Could not create socket: $!\n" unless $sock;<br><br>my $make_call;<br>my $con;<br>my $type = "user/";<br><br>for(;;) {<br> my $new_sock = $sock->accept();<br> my $pid = fork();<br>
if ($pid) {<br> close($new_sock);<br> next;<br> }<br> my $host = $new_sock->sockhost();<br> my $fd = fileno($new_sock);<br> $con = new ESL::ESLconnection($fd);<br>
my $info = $con->getInfo();<br> my $uuid = $info->getHeader("unique-id");<br> printf "Connected call %s, from %s to %s\n", $uuid, $info->getHeader("caller-caller-id-number"), $info->getHeader("caller-destination-number");<br>
<br> $con->filter("Unique-Id", $uuid);<br> $con->events("plain", "all");<br> $con->execute("answer");<br> $con->setEventLock("true");<br>
my $number=$con->execute("read","2 4 /usr/local/freeswitch/sounds/en/us/callie/conference/8000/conf-pin.wav accnt_number 5000 #");<br> while($con->connected())<br> {<br> my $e=$con->recvEvent();<br>
my $ename=$e->getHeader("Event-Name");<br> my $app=$e->getHeader("Application");<br> if($ename eq "CHANNEL_EXECUTE_COMPLETE" and $app eq "read")<br>
{<br> my $num=$e->getHeader("variable_accnt_number");<br> print "$num\n";<br> $con->execute("hangup");<br>
}<br> }<br> if(!$con->connected())<br> {<br> print "Connection not exists\n";<br> $con = new ESL::ESLconnection($fd);<br> $con->api("originate","user/1000 &park()");<br>
print "Hai\n";<br> }<br> print "Bye\n------------------------------------------------------------------\n";<br> close($new_sock);<br>}<br>Output:<br>Connected call 6b713588-d8c5-11de-8d50-596fac84e59e, from 1000 to 9097<br>
1000<br>Connection not exists<br>Hai<br>Bye<br>------------------------------------------------------------------<br>The freeswitch log is in<br><a href="http://pastebin.freeswitch.org/11258" target="_blank"><a href="http://pastebin.freeswitch.org/11258">http://pastebin.freeswitch.org/11258</a></a><br>
<br>I also noted that, if I don't receive any events, especially "SERVER_DISCONNECTED", then the connection is in established state, but once I receive the "SERVER_DISCONNECTED" event, the connection is closed. Is it correct??<div>
<div></div><div class="h5"><br>
<br><br><br><br><div class="gmail_quote">On Tue, Nov 24, 2009 at 1:10 AM, Anthony Minessale <span dir="ltr"><<a href="mailto:anthony.minessale@gmail.com" target="_blank"><a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a></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;">
or open a new outbound connection at the end of your script so you can send your originate command.<br>Since the channel hanging up will close your existing connection since it's only an outbound single session socket.<br>
<br><br><div class="gmail_quote"><div><div></div><div>On Mon, Nov 23, 2009 at 11:51 AM, Michael Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org" target="_blank"><a href="mailto:msc@freeswitch.org">msc@freeswitch.org</a></a>></span> wrote:<br>
</div></div><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><div>
<br><br><div class="gmail_quote"><div><div></div><div>On Mon, Nov 23, 2009 at 3:25 AM, lakshmanan ganapathy <span dir="ltr"><<a href="mailto:lakindia89@gmail.com" target="_blank"><a href="mailto:lakindia89@gmail.com">lakindia89@gmail.com</a></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;">
Hi,<br>I'm using perl ESL to control the call in freeswitch.<br>I'm having the following scenario, but not able to get it right.<br><br>Dialplan:<br><extension name="outbound_soc"><br> <condition field="destination_number" expression="^9097$"><br>
<action application="set" data="continue_on_fail=true"/><br> <action application="socket" data="<a href="http://192.168.1.222:8447" target="_blank">192.168.1.222:8447</a> async full"/><br>
</condition><br></extension><br><br><br>1. User A calls to an extention (1000).<br>2. My ESL program will be running, and it answers the call.<br>3. Then the program will get a number from the user.<br>4. It will hangup the call.<br>
5. The program has to call to the number that was given by the user.<br><br>In the above scenario, I was able to do until the 4th step. After hangup the call, if I say originate it is not working.<br>Any ideas on how to do this in ESL.<br>
<br></blockquote></div></div><div><br>I want to make sure I understand what the script is supposed to be doing. The caller will key in a phone number to your script and your script will collect those digits. The script will then hangup on the caller and originate a completely new call? Perhaps you could use sched_api to schedule a new originate command for a few seconds into the future and then hangup?<br>
-MC<br></div></div><br>
<br></div></div>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank"><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a></a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank"><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a></a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank"><a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a></a><br>
<a href="http://www.freeswitch.org" target="_blank"><a href="http://www.freeswitch.org">http://www.freeswitch.org</a></a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank"><a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a></a><br>ClueCon <a href="http://www.cluecon.com/" target="_blank"><a href="http://www.cluecon.com/">http://www.cluecon.com/</a></a><br>
Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank"><a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a></a><br><br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank"><a href="http://irc.freenode.net">irc.freenode.net</a></a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:<a href="mailto:888@conference.freeswitch.org">888@conference.freeswitch.org</a></a><br>
<a href="http://iax:guest@conference.freeswitch.org/888" target="_blank">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400<br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank"><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a></a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank"><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a></a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank"><a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a></a><br>
<a href="http://www.freeswitch.org" target="_blank"><a href="http://www.freeswitch.org">http://www.freeswitch.org</a></a><br>
<br></blockquote></div><br>
</div></div></blockquote></div><br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>FreeSWITCH-users mailing list</span><br><span><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a></span><br><span><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a></span><br><span>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users</span><br><span><a href="http://www.freeswitch.org">http://www.freeswitch.org</a></span><br></div></blockquote></body></html>