[Freeswitch-users] Event socket and python

Johan Brannlund freeswitch at nullinfinity.org
Thu Sep 5 01:20:50 MSD 2013


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.



Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list