故障现象

分机 8002 呼叫时,通道创建后约 10 秒被 Abandoned,挂断原因为 WRONG_CALL_STATE,呼叫始终停留在 CS_NEW 状态,未进入正常呼叫流程。

信令层面观察,FreeSWITCH 收到 INVITE 后回复了 407 Proxy Authentication Required,要求终端提供认证信息。终端未正确响应 407(未带认证重发 INVITE),导致呼叫流程中断。

本文覆盖两种场景,最终都表现为 CS_NEW 滞留 10 秒后 Abandoned / WRONG_CALL_STATE:

  • 场景一(下述章节):日志中出现 verifying acl "domains" 行,ACL 检查已执行,但源 IP 不在白名单
  • 场景二(见文末「场景二」章节):日志中不出现任何 ACL 验证/拒绝行,internal profile 未开启 apply-inbound-acl,所有 inbound 统一被 407 挑战

关键日志

1
2
3
4
5
6
f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09 2026-05-14 18:56:26.779513 98.30% [NOTICE] switch_channel.c:1123 New Channel sofia/internal/8002@test.example.internal [f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09]
f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09 2026-05-14 18:56:26.779513 98.30% [INFO] sofia.c:10508 sofia/internal/8002@test.example.internal receiving invite from 192.168.111.15:18627
[DEBUG] sofia.c:10602 verifying acl "domains" for ip/port 192.168.111.15:0.
[DEBUG] sofia.c:2465 detaching session f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09
f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09 2026-05-14 18:56:36.839510 98.30% [WARNING] switch_core_state_machine.c:684 Abandoned
f4df1f3b-2dff-4ac5-ba77-d5f827d1bd09 2026-05-14 18:56:36.839510 98.30% [NOTICE] switch_core_state_machine.c:687 Hangup sofia/internal/8002@test.example.internal [CS_NEW] [WRONG_CALL_STATE]

日志分析(场景一)

时间 事件 说明
18:56:26 New Channel 通道 sofia/internal/8002@test.example.internal 创建,状态 CS_NEW
18:56:26 receiving invite 收到来自 192.168.111.15:18627 的 INVITE
18:56:26 verifying acl 对 192.168.111.15 进行 ACL “domains” 验证
18:56:26 detaching session 会话被 detach,呼叫未继续处理
18:56:36 Abandoned 约 10 秒后通道被标记为 Abandoned
18:56:36 Hangup WRONG_CALL_STATE 挂断,原因 WRONG_CALL_STATE

根因分析(场景一)

日志显示 FreeSWITCH 在验证 ACL “domains” 时,源 IP 192.168.111.15 不在允许的 ACL 列表中。由于该 IP 未通过 ACL 信任,FreeSWITCH 将其视为外部未认证来源,回复 407 Proxy Authentication Required 要求鉴权。但终端未能正确处理 407 挑战(未携带认证信息重发 INVITE),导致会话被 detach,呼叫无法从 CS_NEW 状态正常转移,最终超时以 WRONG_CALL_STATE 挂断。

信令交互流程:

1
2
3
4
5
6
7
终端(192.168.111.15)              FreeSWITCH
| |
|------- INVITE ------------->| 收到 INVITE,ACL 验证失败
|<------ 407 Proxy Auth Req --| 回复 407,要求认证
| | 终端未响应(未带认证重发 INVITE)
| [Abandoned]
| [WRONG_CALL_STATE]

有两种解决思路:

  • 思路一:将源 IP 加入 ACL 白名单,跳过认证,适用于可信内网终端
  • 思路二:确保终端正确配置 SIP 认证信息(用户名/密码),能正确响应 407 挑战

解决方法(场景一)

在 /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml 中,将源 IP 192.168.111.15 添加到 domains ACL 列表中:

1
2
3
4
5
6
7
8
9
10
11
12
13
<configuration name="acl.conf" description="Network Lists">
<network-lists>
<list name="lan" default="allow">
<node type="allow" cidr="192.168.0.0/8"/>
</list>


<list name="domains" default="deny">
<!-- 其他已有节点 -->
<node type="allow" cidr="192.168.0.0/8"/>
</list>
</network-lists>
</configuration>

修改后在 fs_cli 中执行 reloadacl 使配置生效:

1
freeswitch> reloadacl

执行 reloadacl 后的确认日志,可见 192.168.0.0/8 已成功加入 domains 列表:

1
2
3
4
5
6
7
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_core.c:1590 Created ip list lan default (allow)
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_utils.c:667 Adding 172.0.0.1/32 (allow) [] to list lan
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_utils.c:667 Adding 172.17.0.0/16 (allow) [] to list lan
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_utils.c:667 Adding 192.168.0.0/8 (allow) [] to list lan
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_core.c:1590 Created ip list domains default (deny)
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_utils.c:667 Adding 172.17.0.0/16 (allow) [] to list domains
2026-05-14 19:02:20.799556 98.13% [NOTICE] switch_utils.c:667 Adding 192.168.0.0/8 (allow) [] to list domains

验证方法(场景一)

  1. 重新发起呼叫,确认不再出现 Abandoned 和 WRONG_CALL_STATE
  2. 通道应正常从 CS_NEW → CS_INIT → CS_ROUTING → CS_EXECUTE 流转
  3. 信令层面不再返回 407,INVITE 直接进入正常呼叫流程
  4. 可通过 fs_cli 执行 acl_list 查看 ACL 配置是否已加载

场景二:无 ACL 日志,apply-inbound-acl 未开启

故障现象

主叫 888888@tenant-01.example.internal(源 IP 192.168.16.4)呼叫时,通道创建后停留 CS_NEW 状态约 10 秒,随后 Abandoned,挂断原因 WRONG_CALL_STATE。

关键差异:日志中完全没有 verifying acl / ACL 拒绝相关行——收到 INVITE 后直接 detaching session,没有执行任何 ACL 检查。此时 internal profile 未配置 apply-inbound-acl,FreeSWITCH 无法将源 IP 识别为可信来源,统一对 inbound INVITE 回 407 Proxy Authentication Required 挑战;终端未带认证重发 INVITE,会话滞留 CS_NEW 直到 10 秒超时被 Abandoned。

关键日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
★ 2026-08-18 19:09:48.342814 95.90% [NOTICE] switch_channel.c:1123 New Channel sofia/internal/888888@tenant-01.example.internal [545c40e6-56d7-4432-b571-7fe0430c1248]   ← 通道创建,进入 CS_NEW
2026-08-18 19:09:48.342814 95.90% [DEBUG] switch_core_state_machine.c:581 (sofia/internal/888888@tenant-01.example.internal) Running State Change CS_NEW (Cur 2 Tot 25557)
2026-08-18 19:09:48.342814 95.90% [INFO] sofia.c:10510 sofia/internal/888888@tenant-01.example.internal receiving invite from 192.168.16.4:18627 version: 1.10.7-release git 16ff07d 2026-07-16 05:49:57Z 64bit call-id: po8lh268bmmd1ce8gevt ← 收到 INVITE,源 IP 192.168.16.4
2026-08-18 19:09:48.342814 95.90% [DEBUG] switch_core_state_machine.c:600 (sofia/internal/888888@tenant-01.example.internal) State NEW
★ 2026-08-18 19:09:48.342814 95.90% [DEBUG] sofia.c:2465 detaching session 545c40e6-56d7-4432-b571-7fe0430c1248 ← 爆点:无任何 verifying acl 行,直接 detach,回 407 后等待认证
2026-08-18 19:09:58.402819 96.17% [WARNING] switch_core_state_machine.c:684 545c40e6-56d7-4432-b571-7fe0430c1248 sofia/internal/888888@tenant-01.example.internal Abandoned ← 10 秒后 Abandoned
2026-08-18 19:09:58.402819 96.17% [NOTICE] switch_core_state_machine.c:687 Hangup sofia/internal/888888@tenant-01.example.internal [CS_NEW] [WRONG_CALL_STATE] ← 挂断原因 WRONG_CALL_STATE
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:581 (sofia/internal/888888@tenant-01.example.internal) Running State Change CS_HANGUP (Cur 2 Tot 25557)
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:844 (sofia/internal/888888@tenant-01.example.internal) Callstate Change DOWN -> HANGUP
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:846 (sofia/internal/888888@tenant-01.example.internal) State HANGUP
2026-08-18 19:09:58.402819 96.17% [DEBUG] mod_sofia.c:468 Channel sofia/internal/888888@tenant-01.example.internal hanging up, cause: WRONG_CALL_STATE
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:59 sofia/internal/888888@tenant-01.example.internal Standard HANGUP, cause: WRONG_CALL_STATE
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:846 (sofia/internal/888888@tenant-01.example.internal) State HANGUP going to sleep
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:616 (sofia/internal/888888@tenant-01.example.internal) State Change CS_HANGUP -> CS_REPORTING
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:581 (sofia/internal/888888@tenant-01.example.internal) Running State Change CS_REPORTING (Cur 2 Tot 25557)
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:932 (sofia/internal/888888@tenant-01.example.internal) State REPORTING
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:168 sofia/internal/888888@tenant-01.example.internal Standard REPORTING, cause: WRONG_CALL_STATE
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:932 (sofia/internal/888888@tenant-01.example.internal) State REPORTING going to sleep
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:607 (sofia/internal/888888@tenant-01.example.internal) State Change CS_REPORTING -> CS_DESTROY
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_session.c:1753 Session 25557 (sofia/internal/888888@tenant-01.example.internal) Locked, Waiting on external entities
2026-08-18 19:09:58.402819 96.17% [NOTICE] switch_core_session.c:1771 Session 25557 (sofia/internal/888888@tenant-01.example.internal) Ended
2026-08-18 19:09:58.402819 96.17% [NOTICE] switch_core_session.c:1775 Close Channel sofia/internal/888888@tenant-01.example.internal [CS_DESTROY]
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:735 (sofia/internal/888888@tenant-01.example.internal) Running State Change CS_DESTROY (Cur 1 Tot 25557)
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:745 (sofia/internal/888888@tenant-01.example.internal) State DESTROY
2026-08-18 19:09:58.402819 96.17% [DEBUG] mod_sofia.c:379 sofia/internal/888888@tenant-01.example.internal SOFIA DESTROY
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:175 sofia/internal/888888@tenant-01.example.internal Standard DESTROY
2026-08-18 19:09:58.402819 96.17% [DEBUG] switch_core_state_machine.c:745 (sofia/internal/888888@tenant-01.example.internal) State DESTROY going to sleep ← 通道销毁,整个生命周期未离开 CS_NEW

日志分析(场景二)

时间 事件 说明
19:09:48 New Channel 通道 sofia/internal/888888@tenant-01.example.internal 创建,进入 CS_NEW
19:09:48 receiving invite 收到来自 192.168.16.4:18627 的 INVITE
19:09:48 (无 verifying acl 行) 关键差异:与场景一不同,日志未出现任何 ACL 验证行,说明 profile 未开启 apply-inbound-acl
19:09:48 detaching session FreeSWITCH 回 407 挑战后 detach 会话,等待终端带认证重发
19:09:58 Abandoned 10 秒内未收到带认证的 INVITE,通道被标记 Abandoned
19:09:58 Hangup WRONG_CALL_STATE 挂断原因 WRONG_CALL_STATE,通道经 HANGUP → REPORTING → DESTROY 销毁

信令交互流程:

1
2
3
4
5
6
7
终端(192.168.16.4)              FreeSWITCH (internal profile, 未配置 apply-inbound-acl)
| |
|------- INVITE ------------->| 收到 INVITE,无 ACL 检查
|<------ 407 Proxy Auth Req --| 统一对 inbound 回 407 要求认证
| | 终端未带 Authorization 重发 INVITE
| [Abandoned](10 秒超时)
| [WRONG_CALL_STATE]

根因分析(场景二)

internal profile 未开启 apply-inbound-acl,源 IP 192.168.16.4 无法通过 ACL 白名单机制被识别为可信来源。FreeSWITCH 对未通过信任校验的 inbound INVITE 统一回复 407 Proxy Authentication Required;终端未实现(或未配置)407 挑战的响应,未携带 Authorization 头重发 INVITE,会话在 CS_NEW 滞留 10 秒后被状态机 Abandoned,以 WRONG_CALL_STATE 挂断。

与场景一的对比:场景一 ACL 已开启但 IP 不在白名单(日志有 verifying acl 行);场景二 ACL 检查根本未执行(日志无任何 ACL 行),但两者信令结果一致——都被 407 挑战卡住。

解决方法(场景二)

1. 开启 apply-inbound-acl 并将源 IP 加入白名单

编辑 /usr/local/freeswitch/conf/sip_profiles/internal.xml,添加(或取消注释):

1
<param name="apply-inbound-acl" value="domains"/>

同时在 /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml 的 domains 列表中放行源 IP 192.168.16.4:

1
2
3
4
<list name="domains" default="deny">
<!-- 其他已有节点 -->
<node type="allow" cidr="192.168.16.4/32"/>
</list>

2. 使配置生效

1
2
3
4
freeswitch@internal> reloadacl
+OK acl reloaded

freeswitch@internal> sofia profile internal restart

apply-inbound-acl 是 profile 启动时读取的参数,reloadacl 只刷新 ACL 列表本身;修改 profile 参数后需 sofia profile internal restart(或 reloadxml + restart)才能生效。

验证方法(场景二)

1. 在 FreeSWITCH 实例中查询 ACL 是否对源 IP 生效

使用 acl API 命令实时查询(语法 acl <ip> <list_name>):

1
freeswitch@internal> acl 192.168.16.4 domains

期望输出:

1
true    ← 白名单已生效,192.168.16.4 在 domains 列表中,inbound INVITE 将跳过 407

若输出 false,则白名单未生效(IP 不在列表、ACL 未加载、或 profile 参数未生效),inbound 仍会被 407 挑战。

命令行方式(不进 fs_cli 交互):

1
fs_cli -x "acl 192.168.16.4 domains"

2. 重新发起呼叫验证

  1. 重新呼叫,确认不再出现 Abandoned / WRONG_CALL_STATE
  2. 日志中应出现 verifying acl "domains" for ip/port 192.168.16.4:0 且通过检查
  3. 通道正常从 CS_NEW → CS_INIT → CS_ROUTING → CS_EXECUTE 流转
  4. 信令层面 INVITE 不再被 407 挑战(可用 siptrace 抓包确认:sofia global siptrace on)
  5. fs_cli 执行 acl_list 查看 ACL 配置加载情况

RFC 与参考文档

RFC

  • RFC 3261(SIP: Session Initiation Protocol)
    • §22 —— Proxy Authentication 机制:407 响应、Proxy-Authenticate / Proxy-Authorization 头的使用
    • §21.4.8 —— 407 Proxy Authentication Required 状态码定义

参考文档


© 2018–2026 小周周 · 使用 Stellar 构建

站内搜索

没有找到内容!