TCP Reset after 5mins from Azure Load Balancer #19
-
I have configured a Query Stream to consume from a KSQLDB app on a Kafka cluster, the Kafka cluster is managed by Confluent Cloud and hosted on Microsoft Azure in the North Europe region. During off-peak times, my query stream stops receiving messages if the stream has been idle for more than 5 minutes (i.e. no messages in a 5 minute window). Taking a pcap trace using Wireshark I can see that the cluster endpoint I connect to sends a TCP reset after 5 minutes of idle time. This TCP Reset is not interpreted or understood by the "ksqlDB.RestApi.Client" and therefore my app continues listening using the "Subscribe" API even though the underlying TCP connection is in fact closed. I raised this issue with Confluent Cloud support and they could not replicate the issue however they did say that Azure Load Balancers terminate idle TCP connections after about 5 minutes which is very similar if not the exact issue I have. In an attempt to find a solution, I enabled a TCP keep alive over the stream. The solution includes upgrading to .NET6 and replacing http handler "HttpClientHandler" in the "ksqlDB.RestApi.Client" lib with the more feature rich "WinHttpHandler" like so
the "WinHttpHandler" in .NET6 allows me to set the TCP keep alive on the socket along with setting infinite timeouts. This fixed my issue however I would like to know if setting the TCP keep alive can be exposed someway via the "ksqlDB.RestApi.Client" (and built for .NET6). Is something like this possible as I don't want to develop my own lite version of the "ksqlDB.RestApi.Client" for .NET6 with WinHttpHandler in the http pipeline? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @dtcos, Http interception with ksqldb .NET client. Thank you. |
Beta Was this translation helpful? Give feedback.
Hi @dtcos,
could you please try to replace the
InnerHandler
as in the following example?Http interception with ksqldb .NET client.
Thank you.