You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用confluent_kafka.Producer出现SchemaRegistryError(405)问题求助

问题分析与解决

错误根源

你把SchemaRegistryClient的URL配置成了JSON Schema的官方规范地址https://json-schema.org/draft/2020-12/schema,这是完全错误的。这个地址是JSON Schema的文档地址,不是Kafka Schema Registry服务的API地址,所以请求时返回了405 Method Not Allowed(该地址不支持Schema Registry所需的POST/GET等API请求)。

正确配置方案

本地通过kafka-monitoring-stack-docker-compose运行的Kafka栈中,Schema Registry服务默认会暴露8081端口(可查看docker-compose.yml文件里的端口映射确认),你需要将Schema Registry的URL配置为本地服务地址:

from confluent_kafka.schema_registry import SchemaRegistryClient

# 正确的Schema Registry配置
schema_registry_conf = {
    "url": "http://localhost:8081"  # 替换成你实际的Schema Registry服务地址
}
schema_registry_client = SchemaRegistryClient(schema_registry_conf)

额外检查项

  • 运行docker ps命令,确认Schema Registry容器处于Up状态
  • 查看docker-compose.yml中的端口映射,确保8081端口已映射到本地(通常是8081:8081)
  • 可以通过浏览器或curl访问http://localhost:8081/subjects测试服务是否正常响应

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 09:46:32