# SIP/2.0 481 呼叫/事务不存在

- **ID:** `communication/sip-481-loop-detected`
- **领域:** communication
- **类别:** protocol_error
- **错误码:** `481`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

SIP 代理或 B2BUA 收到了一个针对已终止或从未创建的对话或事务的请求，通常是由于分叉请求或 CANCEL 乱序导致。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kamailio 5.7 | active | — | — |
| FreeSWITCH 1.10 | active | — | — |
| Asterisk 20 | active | — | — |
| opensips 3.5 | active | — | — |

## 解决方案

1. ```
   Enable SIP dialog tracking in Kamailio: `modparam("dialog", "track_cseq_updates", 1)` and ensure `dlg_flag` is set on initial INVITE. Also add `failure_route` to handle 481 gracefully by sending ACK and clearing state.
   ```
2. ```
   Configure FreeSWITCH to handle 481 by setting `sip-force-expires` on re-INVITE and enabling `sip-call-id` validation in the dialplan to reject mismatched requests.
   ```
3. ```
   Add a SIP route in Asterisk that matches 481 responses and sends a CANCEL or BYE to clean up the dangling transaction on the upstream leg.
   ```

## 无效尝试

- **Restart the SIP proxy service to clear all dialogs** — The error is caused by dialog state mismatch, not by stale state. Restarting loses all active calls and won't fix the routing logic that creates the mismatch. (95% 失败率)
- **Increase transaction timeout values in SIP config** — 481 is not a timeout error; it's a state machine inconsistency. Longer timeouts only delay the inevitable failure. (85% 失败率)
- **Disable SIP forking entirely** — While forking can contribute to 481 errors, disabling it breaks legitimate call distribution and is an overreaction. The root cause is usually improper dialog tracking. (60% 失败率)
