Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

How to troubleshoot Kafka-Python SSL UNEXPECTED_MESSAGE

How do I troubleshoot this SSL error message when attempting to use Kafka-Python to connect a KafaProducer? I know that the network is good and the Keystore works because I can successfully connect to this server and topic via KaDeck.


def connect_kafka_producer():
    _producer = None
    try:
        _bootstrap = 'b-3.fakedns.kafka.us-east-1.amazonaws.com:9094'
        _producer = KafkaProducer(bootstrap_servers=[_bootstrap] 
            , request_timeout_ms=5000
            , max_block_ms=5000
            , security_protocol="SSL"
            , ssl_keyfile="C:fakepathmykeyname.keystore"
            , ssl_password="fakepassword")
    except Exception as ex:
        print('Exception while connecting Kafka')
        print(str(ex))
    finally:
        return _producer
[SSL: UNEXPECTED_MESSAGE] unexpected message (_ssl.c:1123)

This is all I get from the DEBUG log output.

DEBUG:kafka.metrics.metrics:Added sensor with name connections-closed
DEBUG:kafka.metrics.metrics:Added sensor with name connections-created
DEBUG:kafka.metrics.metrics:Added sensor with name select-time
DEBUG:kafka.metrics.metrics:Added sensor with name io-time
DEBUG:kafka.client:Initiating connection to node bootstrap-0 at b-3.fakedns.kafka.us-east-1.amazonaws.com:9094
DEBUG:kafka.metrics.metrics:Added sensor with name bytes-sent-received
DEBUG:kafka.metrics.metrics:Added sensor with name bytes-sent
DEBUG:kafka.metrics.metrics:Added sensor with name bytes-received
DEBUG:kafka.metrics.metrics:Added sensor with name request-latency
DEBUG:kafka.metrics.metrics:Added sensor with name node-bootstrap-0.bytes-sent
DEBUG:kafka.metrics.metrics:Added sensor with name node-bootstrap-0.bytes-received
DEBUG:kafka.metrics.metrics:Added sensor with name node-bootstrap-0.latency
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <disconnected> [unspecified None]>: creating new socket
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <disconnected> [IPv4 ('10.999.999.999', 9094)]>: setting socket option (6, 1, 1)
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <connecting> [IPv4 ('10.999.999.999', 9094)]>: connecting to b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 [('10.999.999.999', 9094) IPv4]
INFO:kafka.conn:Probing node bootstrap-0 broker version
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <connecting> [IPv4 ('10.999.999.999', 9094)]>: established TCP connection
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <connecting> [IPv4 ('10.999.999.999', 9094)]>: initiating SSL handshake
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <handshake> [IPv4 ('10.999.999.999', 9094)]>: configuring default SSL Context
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <handshake> [IPv4 ('10.999.999.999', 9094)]>: Loading system default SSL CAs from DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='C:\Program Files\Common Files\ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='C:\Program Files\Common Files\ssl/certs')
DEBUG:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=b-3.fakedns.kafka.us-east-1.amazonaws.com:9094 <handshake> [IPv4 ('10.999.999.999', 9094)]>: wrapping socket in ssl context
question from:https://stackoverflow.com/questions/65886936/how-to-troubleshoot-kafka-python-ssl-unexpected-message

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...