我刚开始使用Kafka,想使用kafka-topics-ui
来查看我所遇到的各种主题。
docker-compomse.yml
用于快速设置zookeeper
和kafka
,包括kafka-topics-ui
,schema-registry
和rest-proxy
。
问题:在加载kafka-topics-ui
上的localhost:8000
网站时,当我们单击其中一个主题时,加载进度栏会自动显示动画,并且没有任何主题消息出现!
在查看浏览器JS控制台时,我们发现执行POST请求时出现了 HTTP 415不支持的媒体类型错误:
JS控制台中的错误
angular.js:12587 POST http://localhost:8000/api/kafka-rest-proxy/consumers/kafka_topics_ui_avro_2018-12-02-03-10-39-256 415 (Unsupported Media Type)
(anonymous) @ angular.js:12587
p @ angular.js:12332
(anonymous) @ angular.js:12084
(anonymous) @ angular.js:16832
$digest @ angular.js:17971
$apply @ angular.js:18269
(anonymous) @ angular.js:26999
hg @ angular.js:3734
d @ angular.js:3722
angular.js:14525 HTTP ERROR: Failed at method [POST] [/api/kafka-rest-proxy/consumers/kafka_topics_ui_avro_2018-12-02-03-10-39-256] with error:
{"data":{"error_code":415,"message":"HTTP 415 Unsupported Media Type"},"status":415,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/kafka-rest-proxy/consumers/kafka_topics_ui_avro_2018-12-02-03-10-39-256","data":"{\"name\": \"kafka-topics-ui-avro\", \"format\": \"avro\", \"auto.offset.reset\": \"earliest\", \"auto.commit.enable\": \"false\"}","dataType":"json","headers":{"Content-Type":"application/vnd.kafka.v2+json","Accept":"application/json, text/plain, */*"}},"statusText":"Unsupported Media Type"}
DATA SENT: {"name": "kafka-topics-ui-avro", "format": "avro", "auto.offset.reset": "earliest", "auto.commit.enable": "false"}
出了什么问题,我们该如何解决?
docker-compomse.yml
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
- "9999:9999"
environment:
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
KAFKA_CREATE_TOPICS: "orders:1:1,trades:1:1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
JMX_PORT: 9999
depends_on:
- zookeeper
schema-registry:
image: confluent/schema-registry:latest
ports:
- 8081:8081
links:
- zookeeper
- kafka
depends_on:
- zookeeper
- kafka
rest-proxy:
image: confluent/rest-proxy:latest
ports:
- 8082:8082
links:
- zookeeper
- kafka
- schema-registry
depends_on:
- zookeeper
- kafka
- schema-registry
kafka-topics-ui:
image: landoop/kafka-topics-ui
environment:
# yes localhost as its a client side app outsite of the docker network on your host
- KAFKA_REST_PROXY_URL=http://rest-proxy:8082
- PROXY=true
ports:
- 8000:8000
links:
- rest-proxy
depends_on:
- rest-proxy
答案 0 :(得分:1)
我不确定错误/解决方案,但是我想这与CORS有关,或者您正在使用一些旧的confluent/
码头工人图像...
无论如何,我有一个建议。
Landoop提供了一个名为fast-data-dev
的一体化包装容器,其中包含您想要的所有这些组件(以及一些组件)
在Linux主机上,
docker run --rm --net=host landoop/fast-data-dev
就是这样。访问http://localhost:3030进入fast-data-dev 环境
更多信息(例如,如果您未在Linux上运行):https://github.com/Landoop/fast-data-dev