encode / broadcaster

Broadcast channels for async web apps. 📢
BSD 3-Clause "New" or "Revised" License
1.13k stars 121 forks source link

BROADCAST_URL of Kafka cluster not getting parsed - #51

Closed rohitswarke closed 5 months ago

rohitswarke commented 3 years ago

Issue: BROADCAST_URL for Kafka cluster doesn't get parsed correctly and throws KafkaConnectionError

Sample URL: BROADCAST_URL = 'kafka://server1:port,server2:port,server3:port'

Description: aiokafka client is using collect_hosts method of kafka.conn and while kafka.conn.collect_hosts method collects a comma-separated set of hosts (host:port) https://github.com/dpkp/kafka-python/blob/master/kafka/conn.py#L1485

In broadcaster._backends.kafka we are preparing bootstrap server by passing list of entire netloc string as shown below: https://github.com/encode/broadcaster/blob/master/broadcaster/_backends/kafka.py#L13 self._servers = [urlparse(url).netloc] If we tweak above line with below statement then it will support kafka cluster connection string: self._servers = urlparse(url).netloc.split(',')

Do let me know your thoughts on this.