kafka network_error ai_generated true

java.io.IOException: 无法建立与节点 -1 (localhost/127.0.0.1:9092) 的连接。代理可能不可用。

java.io.IOException: Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

ID: kafka/socket-server-max-too-low

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
1证据数
2023-05-15首次发现

版本兼容性

版本状态引入弃用备注
Kafka 3.4.0 active — — —
Kafka 3.5.0 active — — —
Kafka 3.6.0 active — — —
Kafka 3.7.0 active — — —

根因分析

代理的套接字服务器最大连接数限制已耗尽,因为来自客户端的并发连接数超过了配置的 socket.server.max.connections 值。

English

The broker's socket server max connections limit is exhausted because too many concurrent connections from clients exceed the configured value of socket.server.max.connections.

generic

官方文档

https://kafka.apache.org/documentation/#brokerconfigs_socket.server.max.connections

解决方案

  1. Increase the socket.server.max.connections configuration in server.properties and restart the broker:
    
    socket.server.max.connections=2000
    
    Then monitor connections using: netstat -an | grep :9092 | wc -l
  2. Reduce the number of concurrent connections from clients by implementing connection pooling or batching requests. For example, in a Java consumer, use a single shared KafkaConsumer instance instead of creating per-thread consumers.

无效尝试

常见但无效的做法:

  1. Restart the broker 90% 失败

    Restarting only temporarily resets connections; the underlying limit is unchanged and will be hit again quickly under high load.

  2. Increase heap memory for the broker 95% 失败

    Socket server connections are not directly related to heap memory; the issue is a connection count limit, not memory pressure.