0

When trying to connect with ssl to kafka using kafka-python

Im getting the following error:

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'

I have python v2.7.3 running on (Debian 7 wheezy)
ssl.SSLContex attribute was added from python v2.7.9

it seems that ssl support for kafka-python was introduced from v1.1.0 but it requires python version >= v2.7.9, because of the ssl.SSLContext use.

Is there a way to initiate connection with ssl using lower version of python and kafka-python?
or somehow bypass this?

Maybe someone can suggest another package that supports ssl connection to kafka and supports python version =< 2.7.3.

Urban48
  • 1,398
  • 1
  • 13
  • 26

1 Answers1

0

No, there is no way to do this with kafka-python unless you patch it yourself. Instead, I strongly recommend upgrading to a newer version of python 2.7 as that version of python 2.7 is fairly old and likely has multiple security vulnerabilities (which I assume matter to you if you're trying to use SSL.)

Jeff Widman
  • 22,014
  • 12
  • 72
  • 88