In one of our very simple custom contexts I would like to add some database logging outside of the built-in cdr app. I have something like the following:
在我们一个非常简单的自定义上下文中,我想在内置的cdr应用程序之外添加一些数据库日志记录。
[inbound-custom]
exten => _X.,1,MixMonitor(/mnt/temp/inbound-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}-${UNIQUEID}.wav)
exten => _X.,n,MYSQL(Connect connid mysqlip cdr_logger mysqlpw asteriskcdrdb)
exten => _X.,n,MYSQL(Query resultid ${connid} INSERT INTO `call_recordings` (`asterisk_uniqueid`,`clid`,`filename`,`context`) VALUES (${UNIQUEID},${CALLERID(num)},inbound-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}-${UNIQUEID}.wav,"inbound"))
exten => _X.,n,MYSQL(Clear ${resultid})
exten => _X.,n,MYSQL(Disconnect ${connid})
exten => _X.,n,Dial(SIP/cs1000/${EXTEN})
exten => _X.,n,Hangup()
This seems to work fine for the most part, however if someone hangs up before the context reaches the MYSQL(clear...)
line there is a zombie connection left open on the MySQL server. On the voip info wiki there is mention of doing connection clean up in the h
extension for a context, but there are no samples of this. I tried the following to no avail:
这在很大程度上似乎可以正常工作,但是如果有人在上下文到达MYSQL(clear…)行之前挂起,那么MYSQL服务器上就会有一个僵尸连接。在voip info wiki上,有人提到要在h扩展中对上下文进行连接清理,但没有这样的示例。我试过以下方法,但毫无效果:
[inbound-custom]
exten => _X.,1,MixMonitor(/mnt/temp/inbound-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}-${UNIQUEID}.wav)
exten => _X.,n,MYSQL(Connect connid mysqlip cdr_logger mysqlpw asteriskcdrdb)
exten => _X.,n,MYSQL(Query resultid ${connid} INSERT INTO `call_recordings` (`asterisk_uniqueid`,`clid`,`filename`,`context`) VALUES (${UNIQUEID},${CALLERID(num)},inbound-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}-${UNIQUEID}.wav,"inbound"))
exten => _X.,n,Dial(SIP/cs1000/${EXTEN})
exten => _X.,n,Hangup()
exten => h,1,MYSQL(Clear ${resultid})
exten => h,n,MYSQL(Disconnect ${connid})
I imagine I'm doing something wrong in there but I cant quite tell what it is.
我想我做错了什么,但我不知道它是什么。
1 个解决方案
#1
0
I was able to get this mostly working however clear seems to love throwing errors on inserts and the documentation is minimal at best. Gave up on using MYSQL()
and opted to use system()
to send the insert statement to a waiting python daemon.
我能够做到这一点,但似乎很清楚,在插入和文档中,抛出错误是很容易的。放弃使用MYSQL(),选择使用system()将insert语句发送到等待的python守护进程。
#1
0
I was able to get this mostly working however clear seems to love throwing errors on inserts and the documentation is minimal at best. Gave up on using MYSQL()
and opted to use system()
to send the insert statement to a waiting python daemon.
我能够做到这一点,但似乎很清楚,在插入和文档中,抛出错误是很容易的。放弃使用MYSQL(),选择使用system()将insert语句发送到等待的python守护进程。