I'm running a long-running executable (about 30 minute sessions), but I only need to write to redis once at the very beginning and once at the end of the session.
Thus, I'd like to disconnect my redis connection after the first write, then reconnect at the end, so that I'm not using a persistent connection for all the time in between when I don't need it.
I'm trying to disconnect by wrapping my logic in a using block. However, I get this error (not 100% reproducible, but probably about 50% of the time):
System.InvalidOperationException: Reading is not allowed after reader was completed. at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined)
System.Net.Sockets.SocketException (0x80004005): The I/O operation has been aborted because of either a thread exit or an application request at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.g__ThrowSocketException|10_0(SocketError e)
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at aag.Natives.Api.DeveloperApi.HtmlLogger.ProcessHtmlMessage(DevLogType logType, String message) at aag.Natives.Api.DeveloperApi.LogError(String message) at aag.GameServer.EntryPoint.<>c__DisplayClass47_0.<.ctor>b__1(Object s, FirstChanceExceptionEventArgs e) in E:\dev\LegionTD2_LFS\GameEngine\GameServer\src\GameServer\EntryPoint.cs:line 131 at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at DarkRift.ConnectionService.ChunkReadCallback(IAsyncResult result) at System.Net.LazyAsyncResult.Complete(IntPtr userToken) at System.Net.ContextAwareResult.CompleteCallback(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.ContextAwareResult.Complete(IntPtr userToken) at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Am I going about this the wrong way? Or is this error benign and should be ignored?
User contributions licensed under CC BY-SA 3.0