尝试使用 ssl 连接到 kafka 时kafka-python
我收到以下错误:
Traceback (most recent call last):
File "server.py", line 23, in <module>
kafka_producer = SimpleKafkaProducer()
File "/my-service/kafka_producer.py", line 28, in __init__
self.producer = KafkaProducer(**kafka_config)
File "./ve/lib/python2.7/site-packages/kafka/producer/kafka.py", line 266, in __init__
client = KafkaClient(**self.config)
File "./ve/lib/python2.7/site-packages/kafka/client_async.py", line 130, in __init__
self._bootstrap(collect_hosts(self.config['bootstrap_servers']))
File "./ve/lib/python2.7/site-packages/kafka/client_async.py", line 158, in _bootstrap
bootstrap.connect()
File "./ve/lib/python2.7/site-packages/kafka/conn.py", line 149, in connect
self._wrap_ssl()
File "./ve/lib/python2.7/site-packages/kafka/conn.py", line 207, in _wrap_ssl
self._ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) # pylint: disable=no-member
AttributeError: 'module' object has no attribute 'SSLContext'
我python v2.7.3
在(Debian 7 wheezy)上运行的
ssl.SSLContex
属性是从添加的python v2.7.9
似乎kafka-python
从 v1.1.0 引入了对 ssl 的支持,但由于ssl.SSLContext
使用,它需要 python 版本> = v2.7.9。
有没有办法使用较低版本的 python 和 ssl 启动连接kafka-python
?
或者以某种方式绕过这个?
也许有人可以建议另一个支持 ssl 连接到 kafka 并支持 python 版本 =< 2.7.3 的包。