Skip to content

Unable to catch timeout/refused errors on the client #1491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
7 tasks done
ChillarAnand opened this issue Dec 30, 2022 · 3 comments
Closed
7 tasks done

Unable to catch timeout/refused errors on the client #1491

ChillarAnand opened this issue Dec 30, 2022 · 3 comments
Labels
question usage Incorrect usage

Comments

@ChillarAnand
Copy link

Related issue : #1222 (comment)

Description

When client is polling for new messages, the following errors might happens.

FAIL [rdkafka#consumer-1] [thrd:localhost:9092/bootstrap]: localhost:9092/bootstrap: Connect to ipv6#[::1]:9092 failed: Connection refused (after 0ms in state CONNECT)

FAIL [rdkafka#consumer-3] [thrd:sasl_ssl://foo/3]: foo/3: 1 request(s) timed out: disconnect (after 154583ms in state UP, 1 identical error(s) suppressed)“

I am trying to silence these errors or handle in a different way.

How to reproduce

Use the below script to reproduce the error.

https://github.com/ChillarAnand/avilpage.com/blob/master/scripts/confluent_kafka_consumer.py

To avoid printing these messages, the context manager in the scripting can be used for now.

Checklist

Please provide the following information:

  • confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()):
  • Apache Kafka broker version:
  • Client configuration: {...}
  • Operating system: macOS
  • Provide client logs (with 'debug': '..' as necessary)
  • Provide broker log excerpts - None
  • Critical issue - No
>>> import confluent_kafka
>>> confluent_kafka.version()
('1.7.0', 17235968)
>>> confluent_kafka.libversion()
('1.9.2', 17367807)
@pranavrth
Copy link
Member

If you want to silence these messages, please use filter in the logger. See - logger.addFilter

@ChillarAnand
Copy link
Author

I tried to silence these via consumer, confluent_kafka loggers. But they are not working. However suppressing stderr, stdout is silencing the messages.

Can you please share the logger that is producing the messages? @pranavrth

https://github.com/ChillarAnand/avilpage.com/blob/master/scripts/confluent_kafka_consumer.py

@pranavrth
Copy link
Member

You can use something like this -

class ConnectionRefusedFilter(logging.Filter):
    def filter(self, record):
        return "Connection refused" not in record.getMessage()

logger = logging.getLogger(__file__)
logger.setLevel(logging.ERROR)
f = ConnectionRefusedFilter()
logger.addFilter(f)

@pranavrth pranavrth added question usage Incorrect usage labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question usage Incorrect usage
Projects
None yet
Development

No branches or pull requests

2 participants