-
Notifications
You must be signed in to change notification settings - Fork 53
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
An issue with Established TCP connections after disposing of the client #40
Comments
@OlyaKhruleva, can you please verify on your end that the bug is fixed ? |
Hello, yes I can, but I need some time. I will build the new version and check. I'll let you know, please hold on |
great! thank you! |
I tried to make sense of your results and came up the following:
So, the question shouldn't be whether |
Yes, of course, I was waiting. It is only one screenshot from several tests and monitoring. In the first comment, I have provided systematized information. |
The solution of the problem was: using the singleton instance of Zookeeper client in my API. It is working for me, but with Scoped lifetime (per request) it is not working. Of course, all established connections are closing after API shut down. |
The general case is:
public async void Dispose()
|
.net currently doesn't have syntactic sugar for a using statement that supports async code, that's why i added |
In my code I also tried to close clients with code bellow in sync controller action: |
Do you mean that closeAsync() method can not be used in sync code at all? |
No, as long as you Wait() or await. |
Sorry for the delay, OK, when I will have enough time I will create an isolated project with my realization of work with the client and illustrate the bug. I'll provide it for you. |
Thank you! |
Hello,
I am using the csharp client 3.4.12.1 and zookeeper server 3.4.13 (tried to update to 3.5.5 also). I have the Restful API and creating clients per request, when request ended I disposing of the clients using the closeAsync() method synchronously. When it was disposed I see in code that connection state is closed, but in zookeeper, I see those connections were not closed and every time it increasing (see screenshot 1, I used the telnet with stat command) and count of established TCP ports increasing too (maximum was see screenshots 2,3 - perf monitor, 582 ports).
My maxClientCnxns=500 in zoo.cfg, when I ran the stress test the count of connections was more than 500 and I got the LossException in my code, then count of connections was decreased to 319. In this case, when I shut down the Restful API the ports are release sometimes.
I tried to understand the problem. I tried to rewrite the code in ClientCnxn.close() and disconnect methods: instead of the calling the clientCnxnSocket.wakeupCnxn(); I used the following code:
private async Task disconnect() {
if (LOG.isDebugEnabled()) {
LOG.debug("Disconnecting client for session: 0x"
+ getSessionId().ToHexString());
}
await close();
queueEventOfDeath();
}
private async Task close()
{
state.Value = (int)ZooKeeper.States.CLOSED;
LOG.info("clientCnxnSocket cleanup() in close()");
await clientCnxnSocket.cleanup().ConfigureAwait(false);
LOG.info("clientCnxnSocket close()");
clientCnxnSocket.close();
}
but it was not resolved the issue.
Please advise
The text was updated successfully, but these errors were encountered: