Asterisk - 清理“h”中的 MySQL() 连接扩大
在我们非常简单的自定义上下文之一中,我想在内置 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()
这似乎在大多数情况下工作正常,但是如果有人在上下文到达 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})
我想我在那里做错了什么,但我不太清楚它是什么。
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:
[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:
[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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够让这大部分工作,但显然似乎喜欢在插入上抛出错误,并且文档最多是最少的。放弃使用
MYSQL()
并选择使用system()
将插入语句发送到等待的 python 守护进程。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 usesystem()
to send the insert statement to a waiting python daemon.