dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need help with SSE and .NET events

salarzobir opened this issue · comments

Hey people, I am not even sure whether this is the correct place to ask for help, please forgive me if it is not.

I created this sample ASP.NET Core project https://github.com/salarzobir/SseTest to demonstrate my problem, I am not even sure whether the behavior (message overlapping or process crashing) is a normal intended behavior.

What could be the best way to fix this problem.

In my actual production application I am getting this exception sometimes then the process crashes:

System.ArgumentNullException: Value cannot be null. (Parameter 'array')
   at System.Buffers.SharedArrayPool`1.Return(T[] array, Boolean clearArray)
   at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(Boolean writeToStream, ReadOnlyMemory`1 data, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask`1.GetTaskForValueTaskSource(IValueTaskSource`1 t)
--- End of stack trace from previous location ---
   at MyProject.Services.SseClient.SendAsync[T](T data, String eventType)
   at MyProject.Services.SseService.SendEventAsync[T](IEnumerable`1 clientIds, T data, String eventType)
   at MyProject.Services.SomeService.OnProgressChanged(Object sender, PropertyChangedEventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()