connectexception:连接被拒绝kafka生产者

wj8zmpe1  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(342)

我已经部署Kafka使用 Helm 和minikube。我需要在scala中为需要的代理ip地址和主机构建一个producer。我定义了nodeport服务来向外界公开Kafka。我将代理设置为minkube ip:service node port,但是,我得到了连接异常。我定义的配置有什么问题?使用docker compose文件,应用程序运行良好。
错误堆栈跟踪:

Exception in thread "main" org.apache.kafka.common.errors.SerializationException: Error serializing Avro message
Caused by: java.net.ConnectException: Connection refused (Connection refused)

Kafka的配置如下:

val brokers = "192.168.99.100:32400"
  val props = new Properties()
  props.put("bootstrap.servers", brokers)
  props.put("client.id", "AvroKafkaProducer")
  props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
  props.put("value.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer")
  props.put("schema.registry.url", "http://0.0.0.0:8081")

Kafka节点端口服务定义,其中标签匹配由helm生产的Kafka吊舱:

kind: Service
apiVersion: v1
metadata:
  name: kafka-service
spec:
  selector:
    app: cp-kafka
    release: my-confluent-oss
  ports:
    - protocol: TCP
      targetPort: 9092
      port: 32400
      nodePort: 32400
  type: NodePort

这是所有已创建服务的列表:

NAME                                     TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
my-confluent-oss-cp-kafka                ClusterIP      10.96.241.37     <none>        9092/TCP            6h25m
my-confluent-oss-cp-kafka-connect        ClusterIP      10.105.148.181   <none>        8083/TCP            6h25m
my-confluent-oss-cp-kafka-headless       ClusterIP      None             <none>        9092/TCP            6h25m
my-confluent-oss-cp-kafka-rest           ClusterIP      10.99.154.76     <none>        8082/TCP            6h25m
my-confluent-oss-cp-ksql-server          ClusterIP      10.108.41.220    <none>        8088/TCP            6h25m
my-confluent-oss-cp-schema-registry      ClusterIP      10.108.182.212   <none>        8081/TCP            6h25m
my-confluent-oss-cp-zookeeper            ClusterIP      10.97.148.103    <none>        2181/TCP            6h25m
my-confluent-oss-cp-zookeeper-headless   ClusterIP      None             <none>        2888/TCP,3888/TCP   6h25m
vybvopom

vybvopom1#

错误来自尝试连接到架构注册表的反序列化程序 props.put("schema.registry.url", "http://0.0.0.0:8081") 应该读 props.put("schema.registry.url", "http://<hostname of Schema Registry resolvable from Connect node>:8081")

相关问题