EvoluxBR / greenswitch

Battle proven FreeSWITCH Event Socket Protocol client implementation with Gevent
Other
125 stars 50 forks source link

Handling exceptions when FS disconnects #45

Open badcrc opened 5 years ago

badcrc commented 5 years ago

Hi,

I'm working on a script to capture all callcenter related events based on the example log_reg_attempt.py and it's working good, but if FS restarts I get the error:

Error receiving data, is FreeSWITCH running?

Which comes from receive_events() (line 89).

I'm trying to reconnect or handle this as exception but I'm not having luck. How can I do it to detect the disconnect and reconnect again?

An easy way to test this is just to kill the freeswitch process with the script running.

Thanks!

badcrc commented 5 years ago

Hi,

I managed to have it working by checking fs.connected in the while loop before gevent.sleep(1), if is False I sleep for 10 seconds and then just call fs_login() again.

Thanks!