# AMQPConnectionError: 连接强制关闭 (320) CONNECTION_FORCED

- **ID:** `communication/amqp-connection-forced`
- **领域:** communication
- **类别:** connection_error
- **错误码:** `320`
- **验证级别:** ai_generated
- **修复率:** 83%

## 根因

AMQP 代理（如 RabbitMQ）因资源告警（内存或磁盘）或内部错误强制关闭连接，通常由 connection.blocked 方法指示。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| RabbitMQ 3.11 | active | — | — |
| RabbitMQ 3.12 | active | — | — |
| RabbitMQ 3.13 | active | — | — |

## 解决方案

1. ```
   Check broker resource alarms via `rabbitmq-diagnostics check_alarms` and free up memory/disk. For memory: reduce queue sizes or set `vm_memory_high_watermark` lower. For disk: increase `disk_free_limit`.
   ```
2. ```
   Implement connection recovery with backoff and listen to `connection.blocked` event. In Pika (Python): `connection.add_on_connection_blocked_callback(lambda c: time.sleep(10))`.
   ```

## 无效尝试

- **** — Restarting the client without checking broker resources leads to immediate reconnection and re-disconnection. (80% 失败率)
- **** — Increasing connection timeout doesn't address the underlying resource exhaustion. (90% 失败率)
- **** — Adding more consumer instances worsens resource pressure by creating more connections. (70% 失败率)
