Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance. #98

billrob opened this Issue Mar 2, 2012 · 2 comments


None yet
2 participants

billrob commented Mar 2, 2012

When using the multi-get call we are occasionally receiving this error. It usually happens a few times in a row and then recovers.

Things of note:

We understand the memclient to be thread safe so we have set up our memcached client as a singleton.
We run about 30 memcached queries per second.
We are using version (from nuget)

I found this issue, #94 but it really doesn't seem to apply to us. Any assistance would be helpful.

We might change to instance based, but the pool management might be handled as a singleton anyway under the covers.

System.InvalidOperationException: "An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance.";
at System.Net.Sockets.SocketAsyncEventArgs.StartOperationCommon(Socket socket)
at System.Net.Sockets.Socket.ReceiveAsync(SocketAsyncEventArgs e)
at Enyim.Caching.Memcached.PooledSocket.AsyncSocketHelper.BeginReceive() in d:\d\repo\EnyimMemcached\Enyim.Caching\Memcached\AsyncSocketHelper.cs:line 96
at Enyim.Caching.Memcached.PooledSocket.AsyncSocketHelper.Read(AsyncIOArgs p) in d:\d\repo\EnyimMemcached\Enyim.Caching\Memcached\AsyncSocketHelper.cs:line 81
at Enyim.Caching.Memcached.Protocol.Binary.BinaryResponse.ReadAsync(PooledSocket socket, Action1 next, Boolean& ioPending) in d:\d\repo\EnyimMemcached\Enyim.Caching\Memcached\Protocol\Binary\BinaryResponse.cs:line 99 at Enyim.Caching.Memcached.Protocol.Binary.MultiGetOperation.DoReadAsync() in d:\d\repo\EnyimMemcached\Enyim.Caching\Memcached\Protocol\Binary\MultiGetOperation.cs:line 96 at Enyim.Caching.Memcached.MemcachedNode.ExecuteOperationAsync(IOperation op, Action1 next) in d:\d\repo\EnyimMemcached\Enyim.Caching\Memcached\MemcachedNode.cs:line 502
at Enyim.Caching.MemcachedClient.PerformMultiGet[T](IEnumerable1 keys, Func3 collector) in d:\d\repo\EnyimMemcached\Enyim.Caching\MemcachedClient.cs:line 911

billrob commented Mar 13, 2012

This is running on version 2.11.

I'm going to download Memcached 2.12 Beta 3 and see if that helps.

billrob commented Apr 1, 2012

It has helped somewhat, now we are getting the "Expected Magic Value" exception that @vchekan has been working on.

We are going to wrap the client is another class that will recreate the client. We are currently using Singleton behavior and will recreate the underlying MemcachedClient inside the our Singleton wrapper.

I'm curious as to whether the underlying socket poll is one per client or one per App Domain?


@enyim enyim closed this Apr 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment