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)

是不是我的做法有问题?

相关推荐
无名3872 天前
SIP UDP 分片与 Kamailio——精简 SIP 消息头
通信
无名3873 天前
RTPProxy 2.2 用户手册
通信
xixixi777773 天前
今日 AI 、通信、安全前沿日报(2026 年 2 月 5 日,星期四)
人工智能·网络安全·ai·信息安全·大模型·通信·前沿
无名3873 天前
高吞吐与性能优化:Kamailio调优指南
通信
xixixi777774 天前
今日 AI 、通信、安全行业前沿日报(2026 年 2 月 4 日,星期三)
大数据·人工智能·安全·ai·大模型·通信·卫星通信
无名3875 天前
测试 kamailio v6.0.5 的 nats 模块(预处理)
通信
Trouvaille ~5 天前
【Linux】网络编程基础(二):数据封装与网络传输流程
linux·运维·服务器·网络·c++·tcp/ip·通信
百锦再6 天前
《C#上位机开发从门外到门内》2-7:网络通信(TCP/IP、UDP)
tcp/ip·udp·c#·嵌入式·上位机·通信·下位机
一路向北⁢6 天前
Spring Boot 3 整合 SSE (Server-Sent Events) 企业级最佳实践(一)
java·spring boot·后端·sse·通信
一路向北⁢6 天前
Spring Boot 3 整合 SSE (Server-Sent Events) 企业级最佳实践(二)
java·数据库·spring boot·sse·通信