Skip to content

Akka.IO Bug: An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance #4264

@Aaronontheweb

Description

@Aaronontheweb

Version: Akka.NET v1.4.0-beta4

[ERROR][2/27/2020 2:44:09 AM][Thread 0018][akka://AkkaSpec/system/IO-TCP/$b] "An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance.";
Cause: System.InvalidOperationException: "An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance.";
   at System.Net.Sockets.SocketAsyncEventArgs.StartConfiguring()
   at System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal(Byte[] buffer, Int32 offset, Int32 count)
   at Akka.IO.SocketAsyncEventArgsExtensions.SetBuffer(SocketAsyncEventArgs args, IEnumerable`1 dataCollection) in D:\a\1\s\src\core\Akka\IO\SocketEventArgsPool.cs:line 138
   at Akka.IO.TcpConnection.PendingBufferWrite.DoWrite(ConnectionInfo info) in D:\a\1\s\src\core\Akka\IO\TcpConnection.cs:line 943
   at Akka.IO.TcpConnection.DoWrite(ConnectionInfo info, Option`1 write) in D:\a\1\s\src\core\Akka\IO\TcpConnection.cs:line 532
   at Akka.IO.TcpConnection.<>c__DisplayClass27_0.<HandleWriteMessages>b__0(Object message) in D:\a\1\s\src\core\Akka\IO\TcpConnection.cs:line 367
   at Akka.IO.TcpConnection.<>c__DisplayClass23_0.<Connected>b__0(Object message) in D:\a\1\s\src\core\Akka\IO\TcpConnection.cs:line 223
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message) in D:\a\1\s\src\core\Akka\Actor\ActorBase.cs:line 158
   at Akka.Actor.ActorCell.ReceiveMessage(Object message) in D:\a\1\s\src\core\Akka\Actor\ActorCell.DefaultMessages.cs:line 192
   at Akka.Actor.ActorCell.Invoke(Envelope envelope) in D:\a\1\s\src\core\Akka\Actor\ActorCell.DefaultMessages.cs:line 81

Occurs occasionally when running

[Fact]
public void When_multiple_concurrent_writing_clients_All_acks_should_be_received()
{
const int clientsCount = 50;
new TestSetup(this).Run(x =>
{
// Setup multiple clients
var actors = x.EstablishNewClientConnection();
// Each client sends his index to server
var indexRange = Enumerable.Range(0, clientsCount).ToList();
var clients = indexRange.Select(i => (Index: i, Probe: CreateTestProbe($"test-client-{i}"))).ToArray();
Parallel.ForEach(clients, client =>
{
var msg = ByteString.FromBytes(new byte[1]);
client.Probe.Send(actors.ClientConnection, Tcp.Write.Create(msg, AckWithValue.Create(client.Index)));
});
// All acks should be received
clients.ForEach(client =>
{
client.Probe.ExpectMsg<AckWithValue>(ack => ack.Value.ShouldBe(client.Index), TimeSpan.FromSeconds(10));
});
});
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions