Hi. I've been trying to adapt the Python event socket example at https://github.com/FreeSWITCH/FreeSWITCH/blob/master/libs/esl/python/events.... to do what I want but haven't quite succeeded. In particular, it seems like con.connected is True even if con is not actually connected to anything, like if I try to connect to a port where nothing is listening. The program ------------------------- #!/usr/bin/python import ESL # nothing at all listening on port 8041 con = ESL.ESLconnection("localhost","8041","fakepassword") if con.connected: print "con.connected says we are connected!" con.events("plain", "all"); e = con.recvEvent() if e: print "Event: ",e.serialize() ------------------ prints con.connected says we are connected! Event: Event-Name: SERVER_DISCONNECTED Is this really the intended behaviour? If it is, how would I check that there *actually* is a connection without using con.connected? Look for SERVER_DISCONNECTED events? Any guidance would be much appreciated.
Hi, Try this modified version of your code. It should work. You can also do "while(con.connected())" instead of "while(1)" ============================================== import ESL # Establish an inbound connection to FreeSWITCH con = ESL.ESLconnection("localhost","8041","ClueCon") # set event command to receive all events con.events("plain", "all"); while(1): # or while(con.connected()) e = con.recvEvent() if e: print "Event: ",e.serialize() ====================================================== Here is a Perl version of it as well ====================================================== use ESL; # Establish an inbound connection to FreeSWITCH my $con = new ESL::ESLconnection("localhost", "8021", "ClueCon"); die unless ($con); # set event command to receive all events $con->events('plain','all'); while (1) { my $e = $con->recvEventTimed(10); next unless $e; print $e->serialize(); } ====================================================== -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Johan Brannlund Sent: Wednesday, September 04, 2013 4:21 PM To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] Event socket and python Hi. I've been trying to adapt the Python event socket example at https://github.com/FreeSWITCH/FreeSWITCH/blob/master/libs/esl/python/events. py to do what I want but haven't quite succeeded. In particular, it seems like con.connected is True even if con is not actually connected to anything, like if I try to connect to a port where nothing is listening. The program ------------------------- #!/usr/bin/python import ESL # nothing at all listening on port 8041 con = ESL.ESLconnection("localhost","8041","fakepassword") if con.connected: print "con.connected says we are connected!" con.events("plain", "all"); e = con.recvEvent() if e: print "Event: ",e.serialize() ------------------ prints con.connected says we are connected! Event: Event-Name: SERVER_DISCONNECTED Is this really the intended behaviour? If it is, how would I check that there *actually* is a connection without using con.connected? Look for SERVER_DISCONNECTED events? Any guidance would be much appreciated. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com 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
participants (2)
-
Johan Brannlund
-
Sami Montour