欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

2024/10/27 6:22:39 来源:https://blog.csdn.net/jia198810/article/details/143252158  浏览:    关键词:FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

  • 测试环境
  • 1、 MYODBC 3.51.18 or higher
  • 2、分析和解决
    • 2.1 解决1,降级MySQL ODBC
    • 2.2 解决2,修改FreeSWITCH代码


测试环境

http://myfs.f3322.net:8020/
用户名:admin,密码:admin

FreeSWITCH界面安装参考:https://blog.csdn.net/jia198810/article/details/137820796

1、 MYODBC 3.51.18 or higher

在编译FreeSWITCH,支持ODBC的时候,启动的时候,可能会遇到以下问题:

2020-06-11 07:30:48.559653 [DEBUG] sofia.c:3158 Creating agent for default
2020-06-11 07:30:48.559653 [ERR] switch_odbc.c:522 ERR: [delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%';delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%']
[STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
2020-06-11 07:30:48.559653 [ERR] switch_core_sqldb.c:732 [db="ASTPP";type="odbc"user="astpp_odbc";pass="Iuv4_wuHjU6cqMFXn4Hm"] ODBC SQL ERR [STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%';delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%'
2020-06-11 07:30:48.559653 [CRIT] sofia_glue.c:2625 GREAT SCOTT!!! Cannot execute batched statements! [STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS
2020-06-11 07:30:48.559653 [CRIT] sofia.c:3161 Cannot Open SQL Database [default]!

2、分析和解决

这是因为可能使用高版本的MySQL ODBC版本所致。
FreeSWITCH 需要 MySQL ODBC 支持批处理,即能够一次性执行多个 SQL 语句(通过分号分隔多个SQL语句)。MySQL ODBC 5.x 版本支持通过在 /etc/odbc.ini 中设置 option=67108864 来启用批处理。FreeSWITCH 可以通过 SQLPrepare() 和 SQLExecute() 执行批处理。但是,MySQL ODBC 8.x 之后的版本不支持 option 这个选项,而是可以通过 SQLExecDirect() 来执行多个 SQL 语句。
MySQL ODBC 官网描述如下:
在这里插入图片描述

2.1 解决1,降级MySQL ODBC

要在选定的系统上编译 MySQL ODBC 5.x 版本,并通过设置启动选项 option=67108864 来启用批处理功能。
当前(2024年10月26日)MySQL 官网提供的版本为 mysql-connector-odbc-5.3.13-src.tar.gz。您可以从此链接下载源码包:mysql-connector-odbc-5.3.13-src.tar.gz。下载后,解压并按照官方文档指示进行编译和安装。安装完成后,可以通过在连接字符串中添加 option=67108864 来启用批处理。
在这里插入图片描述
编译后生成libmyodbc5w.so模块,/etc/odbc.ini配置文件使用该模块。

# /etc/odbc.ini
[freeswitch]
DRIVER   = /usr/lib64/libmyodbc5w.so
SERVER   = localhost
PORT     = 3306
DATABASE = freeswitch
USER     = user
PASSWORD = 123456
OPTION   = 67108864
Socket   = /var/run/mysqld/mysqld.sock
CHARSET  = utf8mb4

2.2 解决2,修改FreeSWITCH代码

科技在发展,时代在进步,不可能一直用MySQL ODBC 5.x,目前MySQL ODBC都到9.x版本了,有的新版操作系统,可能也无法编译MySQL ODBC 5.x,会各种兼容报错,因此只能选用新版本的MySQL ODBC。
如果我们可以使用MySQL8.x,使用MySQL ODBC8.x,那么需要修改一下FreeSWITCH的代码,让其使用SQLExecDirect() 执行SQL。

MySQL ODBC8.x的库为libmyodbc8w.so,/etc/odbc.ini使用此库

修改的FreeSWITCH文件是,源码目录下的src/switch_odbc.c,修改如下图:
在这里插入图片描述
重新编译FreeSWITCH可执行文件和库,安装即可。

make
make install

再次启动查看是否还有上面的报错。

祝君好运

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com