Asterisk - 清理“h”中的 MySQL() 连接扩大

发布于 2024-09-15 10:18:48 字数 1620 浏览 7 评论 0原文

在我们非常简单的自定义上下文之一中,我想在内置 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不知在何时 2024-09-22 10:18:48

我能够让这大部分工作,但显然似乎喜欢在插入上抛出错误,并且文档最多是最少的。放弃使用 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 use system() to send the insert statement to a waiting python daemon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文