StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.84k stars 1.5k forks source link

Microsoft.Web.Redis.StackExchangeClientConnection.DeserializeSessionStateItemCollection error "Buffer cannot be null." #2678

Closed stoil-marinov closed 3 months ago

stoil-marinov commented 3 months ago

I am using StackExchange.Redis version 2.6.96 along with Microsoft.Web.RedisSessionStateProvider version 5.0.1 in a Web Forms project targeting .NetFramework 4.81. The web application is running in Azure app service and the session state works just fine with one exception: When I open the application in the browser after it being closed for a while, long enough for the session to have expired, I would get a 500 timeout error. The only way to be able to get the Login page to load, would be to delete any cookies in the browsing history associated with the apps URL. Then, examining the logs, I would find an error like this, that happens upon the timeout. There is no code of mine involved in the stack trace below:

[ArgumentNullException: Buffer cannot be null. Parameter name: buffer] System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable) +13009077 System.IO.MemoryStream..ctor(Byte[] buffer) +12 Microsoft.Web.Redis.StackExchangeClientConnection.DeserializeSessionStateItemCollection(RedisResult serializedSessionStateItemCollection) +45 Microsoft.Web.Redis.StackExchangeClientConnection.GetSessionData(Object rowDataFromRedis) +82 Microsoft.Web.Redis.RedisConnectionWrapper.TryTakeWriteLockAndGetData(DateTime lockTime, Int32 lockTimeout, Object& lockId, ISessionStateItemCollection& data, Int32& sessionTimeout) +312 Microsoft.Web.Redis.RedisSessionStateProvider.GetItemFromSessionStore(Boolean isWriteLockRequired, HttpContextBase context, String id, CancellationToken cancellationToken, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +868 Microsoft.Web.Redis.d19.MoveNext() +184 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64 Microsoft.AspNet.SessionState.d74.MoveNext() +701 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64 Microsoft.AspNet.SessionState.d__65.MoveNext() +659 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64 Microsoft.AspNet.SessionState.TaskAsyncHelper.EndTask(IAsyncResult ar) +63 Microsoft.AspNet.SessionState.SessionStateModuleAsync.EndAcquireState(IAsyncResult result) +6 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +481 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +109 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163

Thank you, Stoil

mgravell commented 3 months ago

This looks like it should be re-logged here /cc @philon-msft

(not trying to be dismissive, but that code is not part of this repository, so there's nothing "we" can do)

stoil-marinov commented 3 months ago

Thank you for the pointer. I found helpful information there.