AspNetCore.Identity.LiteDB breaks on Ubuntu
I have been building a small application for my book club. To make iterating easier I have decided to use the excellent LiteDB database to store all the data. Since the web application also needs to store user data, I have searched for a package that would let me use LiteDB as an identity backend. I have found AspNetCore.Identity.LiteDB, which worked great, until I have tried to deploy it on my usual Ubuntu 18.04 LTS server.
On Windows it worked perfectly but on Ubuntu I have started getting these weird connection and socket errors at an alarming rate:
System.InvalidOperationException: Handle is already used by another Socket.
at System.Net.Sockets.SocketAsyncEngine.RegisterCore(IntPtr socketHandle, SocketAsyncContext context)
at System.Net.Sockets.SocketAsyncEngine.RegisterSocket(IntPtr socketHandle, SocketAsyncContext context)
at System.Net.Sockets.SocketAsyncContext.Register()
at System.Net.Sockets.SocketAsyncContext.OperationQueue`1.StartAsyncOperation(SocketAsyncContext context, TOperation operation, Int32 observedSequenceNumber, CancellationToken cancellationToken)
at System.Net.Sockets.SocketAsyncContext.ReceiveAsync(Memory`1 buffer, SocketFlags flags, Int32& bytesReceived, Action`5 callback, CancellationToken cancellationToken)
at
[ omitted ]
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
2021-03-09 20:12:41.218 +00:00 [Warning] Connection processing ended abnormally.
System.InvalidOperationException: Handle is already used by another Socket.
at System.Net.Sockets.SocketAsyncEngine.RegisterCore(IntPtr socketHandle, SocketAsyncContext context)
at System.Net.Sockets.SocketAsyncEngine.RegisterSocket(IntPtr socketHandle, SocketAsyncContext context)
at System.Net.Sockets.SocketAsyncContext.Register()
[ omitted ]
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication`1 application)
That is to say, sometimes over 90% of requests ended with a Handle is already used by another Socket
, or Connection processing ended abnormally.
.
System.InvalidOperationException: Handle is already used by another Socket
For a long time I have been completely stumped. I have tried remote debugging, but that didn't work for me on Ubuntu - the debugger connected, then froze and died every time.
By the process of elimination I have eventually determined this identity nugget to be the culprit. And sure enough once I have removed it and replaced it completely with a sqlite equivalent, the issues disappeared.
I am not trying to bash on the package or its developer. It doesn't even seem to be in active development. It's also important to note that since I have encountered some bugs with it right from the start, I haven't used the version from NuGet - I built my own, with its LiteDB reference updated to 5.0.10. I'm just posting this in case someone else is googling for these errors.