Closed iicervantes closed 6 years ago
Use Promise.race([])
for init()
call with timeout in your code.
Only problem with this workaround is that the logs are going to get filled with the same error since it wont stop to reconnect. It would be nice for the consumer to have a "retriesAttempt" option like the producer. Say you know a broker will be down for certain amount of hours, there's no point in trying to reconnect.
This will do for now. Thanks for the support!
Currently, when a simple consumer attempts to connect to a broker but for some reason it cannot connect, no-kafka tries to connect, according to reconnectionDelay. Other than reading logs, there is no way to catch the "NoKafkaConnectionError" error when running consumer.init(). The promise for this function is never rejected and hence I cannot move forward.
ERROR no-kafka-client Metadata request failed: NoKafkaConnectionError [hostname:port]: Connection timeout { [NoKafkaConnectionError: Connection timeout] name: 'NoKafkaConnectionError', server: 'hostname:port', message: 'Connection timeout' }
--This is the error is that spits out when pointing to a broker that is down.
Is there any way to catch this error? Annoyingly, it fills up my logs.