wbarnha / kafka-python-ng

Fork for Python client for Apache Kafka
https://wbarnha.github.io/kafka-python-ng/
Apache License 2.0
42 stars 4 forks source link

Fix ssl connection #178

Closed dingxiong closed 2 months ago

dingxiong commented 2 months ago

See issue https://github.com/wbarnha/kafka-python-ng/issues/177

For SSL protocol, the socket will be wrapped inside a SSLSocket instance, and the original socket will be detached, i.e., closed without closing the underlying file description. This leads to -1 socket.fileno inside Epoll selector.
This does not create any problem until https://github.com/wbarnha/kafka-python-ng/pull/156 , which unregisters fd based on socket.fileno.

We can just check key.fd instead of key.fileob.fileno() on top of https://github.com/wbarnha/kafka-python-ng/pull/156, but I think a better solution is to handle SSL socket more gracefully. Having a registered socket with key.fd != key.fileobj.fileno() is error-prone in my opinion.

wbarnha commented 2 months ago

Besides the aforementioned change I've suggested, everything else here I agree with. Thanks a bunch, I'm looking forward to getting this merged.