kafka network_error ai_generated true

java.io.IOException: 对端重置连接(套接字写入错误)

java.io.IOException: Connection reset by peer (Socket write error)

ID: kafka/network-exception-connection-reset

其他格式: JSON · Markdown 中文 · English
78%修复率
83%置信度
1证据数
2023-06-12首次发现

版本兼容性

版本状态引入弃用备注
2.8.0 active
3.2.0 active
3.5.0 active

根因分析

Kafka代理因请求超时、网络不稳定或代理过载而强制关闭TCP连接,导致套接字写入失败。

English

Kafka broker forcefully closed TCP connection due to request timeout, network instability, or broker overload causing socket write failure.

generic

官方文档

https://kafka.apache.org/documentation/#network

解决方案

  1. 增加代理的 'queued.max.requests' 到500以处理突发流量并减少连接重置。
  2. 启用 'connections.max.idle.ms' 并设置为较低值(例如60000),以清理空闲连接并减少资源争用。
  3. 在生产者的重试逻辑中添加指数退避,以处理瞬态连接重置。

无效尝试

常见但无效的做法:

  1. 70% 失败

    Socket timeout affects idle connections, not active writes; connection reset still occurs on overload.

  2. 85% 失败

    Firewall may cause resets, but disabling it is not a production fix; root cause is broker-side overload.

  3. 60% 失败

    Backoff delays reconnection but does not prevent reset during active write; error occurs before backoff.