FreeSWITCH mod_curl 和 mod_xml_rpc 测试

编辑 /usr/local/freeswitch/conf/autoload_configs/xml_rpc.conf.xml

<configuration name="xml_rpc.conf" description="XML RPC">

<settings>

<param name="http-port" value="8889"/>

<param name="commands-to-log" value=".*"/>

</settings>

</configuration>

fs_cli -x 'load mod_xml_rpc'

fs_cli -x 'load mod_curl'

fs_cli -x 'curl http://127.0.0.1:8889/xmlapi/status'

哈哈,结果不错


api 要带参数怎么弄?

fs_cli -x 'curl http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8'

-ERR No such channel!

2025-06-13 16:19:35.493126 98.43% [DEBUG] mod_curl.c:209 method: get, url: http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8, content-type: (null)

2025-06-13 16:19:35.513144 98.43% [INFO] mod_xml_rpc.c:1088 Executed HTTP request command: [uuid_kill 735cc8f4-758a-4efd-b110-c0840e721ce8].


带 http 头要怎么弄?

fs_cli -x "curl http://127.0.0.1:8889/xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8 append_headers 'k1:v111' append_headers 'k2:v222'"

抓包, 用 wireshark 看,如下

GET /xmlapi/uuid_kill?735cc8f4-758a-4efd-b110-c0840e721ce8 HTTP/1.1

Host: 127.0.0.1:8889

User-Agent: freeswitch-curl/1.0

Accept: */*

k1:v111

k2:v222


增加 basic 认证

<configuration name="xml_rpc.conf" description="XML RPC">

<settings>

<param name="http-port" value="8889"/>

<param name="auth-realm" value="freeswitch"/>

<param name="auth-user" value="freeswitch"/>

<param name="auth-pass" value="works"/>

<param name="commands-to-log" value=".*"/>

</settings>

</configuration>

按 mod_curl 文档

fs_cli -x 'curl http://freeswitch:work@127.0.0.1:8889/xmlapi/status'

但实际上,得到 401,不灵

下面是文档片段

If you want to pass basic authentication credentials then do this:

local auth_url = "http://username:password@mysecure_web_service.com"

local response = api:execute("curl", auth_url)

是不是我的做法有问题?

相关推荐
普中科技1 天前
【普中STM32F1xx开发攻略--标准库版】-- 第 38 章 RS485 通信实验
stm32·单片机·嵌入式硬件·开发板·通信·rs485·普中科技
xixixi777771 天前
2026 年 03 月 20 日 AI+通信+安全行业日报(来更新啦)
大数据·人工智能·安全·ai·大模型·通信
嵌入小生0071 天前
硬件 --- 通信 --- uart/通信方式/电平标准/通信方向
uart·通信·串行通信·并行通信·电平标准·通信方向
xixixi777771 天前
5G核心网核心之辨:从服务化架构(SBA)到网络切片的深度实践解析
人工智能·网络安全·信息与通信·通信
问道飞鱼1 天前
【Tauri框架学习】Tauri 与 React 前端集成:通信机制与交互原理详解
前端·学习·react.js·rust·通信
421!2 天前
ESP32学习笔记之UART
笔记·学习·嵌入式·esp32·通信
物联通信量讯说3 天前
从5G迈向未来通信时代,量讯物联深耕连接基础能力
物联网·5g·信息与通信·iot·通信·6g·量讯物联
xixixi777775 天前
详细梳理移动通信技术从1G到5G(及展望6G)的核心特征、区别以及迭代背后的驱动原因
人工智能·网络安全·信息与通信·通信
liulilittle7 天前
OPENPPP2静态隧道UDP中断问题排查与解决
网络·网络协议·ubuntu·udp·debian·信息与通信·通信
xixixi777778 天前
从图灵测试到大模型:人工智能的演进之路(最近open claw及重看流浪地球有感)
安全·ai·大模型·模型·通信