question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to detect connection failures and is there a hard limit for re-connection?

See original GitHub issue

The consumer currently attempts to re-connect to brokers after encountering connectivity issues. Is it possible to apply a global timeout/limit to consumer’s re-connection or disable it completely? Is it possible to somehow detect the connection loss in the user code?

As it stands, the messages processed lately are by definition incorrect in the system I work on, so I have a side channel that can invalidate the output for my clients. In general, I would prefer getting an exception from Consume to losing time on re-connection attempts that take longer than a few seconds when all brokers are not available.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
amirvalhallacommented, Jul 19, 2022

@quixoticaxis , so as far as I don’t know for what kind of business your writing codes , I’m suggesting you to use AdminClient to managing your brokers etc… , whenever you get all your brokers or just specific broker is/are unavailable you can clean/delete your topics by this way your clients couldn’t get any more messages from Kafka , meanwhile whenever your brokers come available again , your producer will create topics again and other cycles will occure

1reaction
amirvalhallacommented, Jul 19, 2022

The consumer currently attempts to re-connect to brokers after encountering connectivity issues. Is it possible to apply a global timeout/limit to consumer’s re-connection or disable it completely? Is it possible to somehow detect the connection loss in the user code?

As it stands, the messages processed lately are by definition incorrect in the system I work on, so I have a side channel that can invalidate the output for my clients. In general, I would prefer getting an exception from Consume to losing time on re-connection attempts that take longer than a few seconds when all brokers are not available.

hi @quixoticaxis

about your first question (set timeout/limit consumer connection) , you can use SessionTimeoutMs property in ConsumerConfig , E.g

var consumerConfig = new ConsumerConfig()
{
    SessionTimeoutMs = (int)TimeSpan.FromSeconds(10).TotalMilliseconds;
};

about your second question to detecting the bootstrap server is available or not I’ll refer you to this link. in result , you should use AdminClient to managing your topics , brokers etc…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client Reconnection - signalr
My understanding of the (JavaScript) hub client is that if a connection is lost, it enters a 'Reconnecting...' phase which attempts to reconnect...
Read more >
Reasons for connectivity failures between availability replicas
This article describes the different possible reasons for a connection failure between replicas participating in an Always On availability ...
Read more >
Connection state recovery - Ably FAQs
Connection state recovery · How many messages will you store whilst a client is disconnected? There is no hard limit so we will...
Read more >
Citrix Director - Failure Reasons Troubleshooting Guide
Check in the Director console to see if the client currently has an active connection, which means no user would be currently impacted....
Read more >
Error Handling and Recovery - Bunny
When Bunny detects TCP connection failure, it will try to reconnect every 5 seconds. Currently there is no limit on the number of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found