[asterisk-users] mySQL connection testing

Andrew Thomas andy at datavox.co.uk
Thu Mar 3 08:42:42 CST 2011


Does anybody know of a way to test whether a mySQL connection invoked
from the dialplan is current or not?

For example:

extensions.conf
===============
[context]
exten => _X.,1,MYSQL(Connect connid localhost user pass db)
exten => _X.,n,MYSQL(Query resultid ${connid} SELECT `something` FROM
`table` WHERE `number` = ${EXTEN})
exten => _X.,n,MYSQL(Fetch foundRow ${resultid} something)
exten => _X.,n,MYSQL(Clear ${resultid})
exten => _X.,n,Wait(10) ; just for fun
exten => _X.,n,MYSQL(Disconnect ${connid})
exten => _X.,n,Hangup()

exten => h,1,MYSQL(Disconnect ${connid})


Now if the caller hangs up before the 10 second timeout - then all is
well.  But, if they don't, Asterisk tries to disconnect an already
disconnected connection.  I need a way of detecting that the connection
has already been disconnected - so I don't try and disconnect it again.

Something like: exten => h,1,ExecIf(CHECK IF CONNECTION STILL OPEN - IN
CASE CALLER HUNG UP AFTER TIME-OUT)?MYSQL(Disconnect ${connid}))

Any ideas?

Ta


 If you have received this communication in error we would appreciate
you advising us either by telephone or return of e-mail. The contents
of this message, and any attachments, are the property of DataVox,
and are intended for the confidential use of the named recipient only.
If you are not the intended recipient, employee or agent responsible
for delivery of this message to the intended recipient, take note that
any dissemination, distribution or copying of this communication and
its attachments is strictly prohibited, and may be subject to civil or
criminal action for which you may be liable.
Every effort has been made to ensure that this e-mail or any attachments
are free from viruses. While the company has taken every reasonable
precaution to minimise this risk, neither company, nor the sender can
accept liability for any damage which you sustain as a result of viruses.
It is recommended that you should carry out your own virus checks
before opening any attachments. 

Registered in England. No. 27459085.





More information about the asterisk-users mailing list