PyKafka metadata in bytes instead of strings

Cho*_*eat 5 python apache-kafka pykafka

I see an unusual behaviour with PyKafka, a client that I just recently began to use.

The error is the following:

Failed to connect newly created broker for b'4758e4ee1af6':9092
{0: <pykafka.broker.Broker at 0x7f319e19be10 (host=b'4758e4ee1af6',port=9092, id=0)>}
Run Code Online (Sandbox Code Playgroud)

The source of the error is in this lines:

    self.client = KafkaClient(hosts=BROKER_ADDRESS, broker_version="0.10.1.0")
consumer = self.client.topics[bytes(self.input_topic,"UTF-8")].get_balanced_consumer(
        consumer_group=bytes(self.consumer_group,"UTF-8"),
        auto_commit_enable=True
    )
Run Code Online (Sandbox Code Playgroud)

Debugging I saw that the client use the correct string IP to connect to the seed broker but when the list of brokers is retrieved, their IP are in binary and when PyKafka tries to connect again to create a consumer, these IPs obviously don't work.

Another problem, possibly connected, is that I need to convert topic names and consumer groups names to bytes by myself (like with other clients) but all the examples in the docs show the usage of strings.

Kafka broker version: 0.10.1.0 PyKafka version: 2.7.0

Cho*_*eat 3

好吧,我完全被误导了:那不是 IP,而是 Base64 格式的主机名(由 Docker 生成)。