IBM / sarama

Sarama is a Go library for Apache Kafka.
MIT License
11.57k stars 1.76k forks source link

Write i/o timeout when Closing TLS connection #1722

Closed KenjiTakahashi closed 1 year ago

KenjiTakahashi commented 4 years ago
Versions
Sarama Kafka Go
v1.26.4/0189d59 2.5.0 1.14.4
Configuration

Really the important part is TLS Enabled, i.e.

config.Net.TLS.Enable = true
config.Net.TLS.Config = tlsConfig
Logs

Again, the relevant part is this log.

[SARAMA] 2020/06/11 10:24:59 Error while closing connection to broker localhost:9092: write tcp [::1]:37390->[::1]:9092: i/o timeout
Problem Description

After enabling TLS, the above error happens on client Close() call. Without TLS, everything works fine. I went down to it and figured that the culprit is https://github.com/Shopify/sarama/blob/0189d59e5253ee7aa2a9eb50bffd18a69460630d/broker.go#L309 but that's probably because it's the first write executed on the connection?

Going further, I found out that removing deadline from https://github.com/Shopify/sarama/blob/0189d59e5253ee7aa2a9eb50bffd18a69460630d/broker.go#L708 (or setting it to time.Time{}) removes the problem. Then I found this report https://github.com/golang/go/issues/13828 stating that SetWriteDeadline does not seem to work properly on TLS Clients. Which appears to be (still) true.

Honestly, not sure what can realistically be done about it in sarama, removing deadlines does not sound like viable solution. Still thought I will share my findings.

d1egoaz commented 4 years ago

maybe @dnwe has more information about this. He added something similar here https://github.com/Shopify/sarama/pull/1529

ghost commented 3 years ago

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.