[asterisk-dev] Persistent connection reconnect problem

Danijel Korzinek danijel.korzinek at pjwstk.edu.pl
Wed Feb 3 13:01:55 CST 2010


Hi,

I'm currently working on an opensource ASR module for Asterisk:
http://forge.asterisk.org/gf/project/julius/

I have a problem, where I need to keep a persistent network connection
open for optimal results. While it would be ideal to open a connection
each time we get a call, the chosen ASR engine is designed to "restart"
after each connection and this takes several seconds. To avoid having to
wait a up to 3 seconds each time a user calls, I decided to keep the
socket open all the time while Asterisk is running and send the engine
to "sleep" when there's no call pending.

Problem is what to do if the connection gets broken (eg. someone unplugs
the network cable) at some time. I have to implement a reconnect
mechanism to avoid having to restart the whole of Asterisk each time
this happens.

I think the most convenient method would be to have a background thread
polling each unused connection and reconnecting them if possible. What
Asterisk methods should I use to achieve this?

Thanks,
Danijel Korzinek



More information about the asterisk-dev mailing list