krakend / krakend-pubsub

a pubsub backend for the KrakenD framework
https://www.krakend.io
Apache License 2.0
10 stars 17 forks source link

Post "kafka:///": unsupported protocol scheme "kafka" #17

Closed Vido closed 2 years ago

Vido commented 2 years ago

Environment info:

Describe the bug

For some reason, krakend can't post to kafka

krakend_1    | 2022/08/30 16:02:44 KRAKEND ERROR: [ENDPOINT: /v1/data] Post "kafka:///": unsupported protocol scheme "kafka"
krakend_1    | [GIN] 2022/08/30 - 16:02:44 | 500 |     382.309µs |      172.25.0.1 | POST     "/v1/data"

Your configuration file:

Please checkout my environment: https://github.com/Vido/krakend-kafka-poc

This repo has all you need to reproduce this error

I used different backend version, but I always get the same:

{
  "$schema": "https://www.krakend.io/schema/v3.json",
  "version": 3,
  "name": "KrakenD - API Gateway",
  "timeout": "30s",
  "cache_ttl": "300s",
  "endpoints": [
    {
      "endpoint": "/v1/data",
      "method": "POST",
      "output_encoding": "json",
      "backend": [
        {
          "host": ["kafka://"],
          "disable_host_sanitize": true,
          "extra_config": {
            "backend/pubsub/publisher": {
              "topic_url": "my_favorite_topic"
            }
          }
        }
      ],
      "input_headers": [
        "Host"
      ]
    }
  ]
}

Commands used Please, check the repo link above

# Setup the env
docker-compose up

# make requests
python krakend_client.py

Expected behavior A clear and concise description of what you expected to happen.

Logs

krakend_1    | 2022/08/30 16:02:44 KRAKEND ERROR: [ENDPOINT: /v1/data] Post "kafka:///": unsupported protocol scheme "kafka"
krakend_1    | [GIN] 2022/08/30 - 16:02:44 | 500 |     382.309µs |      172.25.0.1 | POST     "/v1/data"
Vido commented 2 years ago

I found out the problem:

  kafka:
    image: 'bitnami/kafka:latest'
    healthcheck:
      test: ["CMD-SHELL", "kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --topic my_favorite_topic --describe"]
      interval: 5s
      timeout: 5s
      retries: 5
  krakend:
    image: devopsfaith/krakend:2.0.6
      - "8080:8080"
    depends_on:
      kafka:
        condition: service_healthy