-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Akka.IO] TcpListener connection queue problem #5988
Comments
Is that .NET 6 only? |
Not sure, I can see the code in .NET 5.0, would have to check the .NET Standard API to see if its there |
Nope, not available in .NET Standard 2.0. Introduced in .NET 5.0. |
We can do an |
I'm working with this issue and find that
_socket.AcceptAsync will be called automatically after accepting current connection. Do we need to change it to real pull mode? |
Second question about
If we take a look at MSDN example of SocketAsyncEventArgs usage at this page we can see that it use only one object for
Moreover, we have this code in
If usage of SAEA is very short in fact we can use only one element of array SAEA. |
We can't reduce the SAEA to a single SAEA. The point of using asynchronous event model is to make sure that the server socket can accept multiple incoming connection asynchronously without blocking. This is described in the MS documentation:
|
Wouldn't |
Ok, i was confused by MS example in the same post.
Yes, but after you call
|
Version Information
Version of Akka.NET? dev branch
Which Akka.NET Modules? Akka.IO
Describe the bug
The way TcpListener is accepting new connection is buggy. JVM managed TCP sockets through the nio channel selector pattern while we're doing it closer to bare metal by requesting actual sockets for each incoming connection.
The way it is done in JVM is to use an accepting limit that is being decremented each time a new channel is created, in our case we used SocketAsyncEventArgs as an async non-blocking way of accepting connections (https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka/IO/TcpListener.cs#L68-L79).
PostStop
. But they're not. This array is being overwritten when aResumeAccepting
command is received, possibly creating a memory leak (https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka/IO/TcpListener.cs#L100-L103)We can probably improve this this by ditching SAEA and use_socket.AcceptAsync(null, cancellationToken)
instead. The SAEA would be managed by the method and all pending accept command can be cancelled using the token.The text was updated successfully, but these errors were encountered: