kafka
network_error
ai_generated
true
org.apache.kafka.common.errors.NetworkException: 服务器在收到响应前断开连接。超时时间:30000 毫秒
org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received. Timeout: 30000 ms
ID: kafka/network-exception-read-timeout
82%修复率
88%置信度
1证据数
2023-06-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| kafka_2.13-3.3.1 | active | — | — | — |
| kafka_2.13-3.4.0 | active | — | — | — |
| kafka_2.13-3.5.0 | active | — | — | — |
根因分析
Kafka 代理在发送响应前关闭了 TCP 连接,通常是由于请求超时或客户端与代理之间的网络拥塞。
English
Kafka broker closed the TCP connection before sending a response, often due to request timeout or network congestion between client and broker.
官方文档
https://kafka.apache.org/documentation/#networking解决方案
-
Increase `broker.request.timeout.ms` in `server.properties` (e.g., from 30000 to 60000) and restart the broker to allow longer processing time for slow requests.
-
Enable TCP keepalive on both client and broker: set `socket.connection.setup.timeout.ms=10000` and `socket.connection.setup.timeout.max.ms=30000` in `server.properties`, and on the client set `connections.max.idle.ms=300000`.
-
If using a load balancer, check idle timeout settings (e.g., AWS NLB idle timeout) and increase them to match Kafka's `connections.max.idle.ms`.
无效尝试
常见但无效的做法:
-
85% 失败
The timeout is on the broker side; increasing client timeout does not prevent the broker from disconnecting.
-
90% 失败
Network issues (e.g., firewall, TCP keepalive) persist after reboot; the error recurs on the next request.
-
70% 失败
Disabling socket timeout can cause resource exhaustion and does not address the root cause of disconnection.