Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

LongPollingTransport threw ObjectDisposedException in AbortResetEvent.Set() #1691

Closed
jcondex opened this Issue · 1 comment

3 participants

@jcondex

LongPollingTransport threw an ODE complaining that AbortResetEvent had already been disposed.

This happened because HttpBasedTransport was disposed and then the finally block of PollingLoop occurred.

Here is the exception:

System.ObjectDisposedException was unhandled by user code
  HResult=-2146232798
  Message=Safe handle has been closed
  Source=mscorlib
  ObjectName=""
  StackTrace:
       at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
       at Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
       at System.Threading.EventWaitHandle.Set()
       at Microsoft.AspNet.SignalR.Client.Transports.LongPollingTransport.<>c__DisplayClassc.<PollingLoop>b__0(Task`1 task) in c:\Users\jconde\Documents\GitHub\SignalR\src\Microsoft.AspNet.SignalR.Client\Transports\LongPollingTransport.cs:line 144
       at System.Threading.Tasks.Task.Execute()
  InnerException: 

A simple fix for this is to do the following in the finally block:

                    if (AbortResetEvent != null && !AbortResetEvent.SafeWaitHandle.IsClosed)
                    {
                        AbortResetEvent.Set();
                    }

ServerSentEvents seems immune to this because AbortResetEvent.Set() is not called within a finally block.

@davidfowl davidfowl was assigned
@davidfowl
Owner

Seens the same error on our CI.

MSBuild.exe Error: 0 : Unobserved task exception: System.ObjectDisposedException: Safe handle has been closed
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
   at System.Threading.EventWaitHandle.Set()
   at Microsoft.AspNet.SignalR.Client.Transports.LongPollingTransport.<>c__DisplayClassc.<PollingLoop>b__0(Task`1 task) in d:\BuildAgent\work\2ebbeab341bc5e27\src\Microsoft.AspNet.SignalR.Client\Transports\LongPollingTransport.cs:line 144
   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
@halter73 halter73 was assigned
@jcondex jcondex was assigned
@davidfowl davidfowl closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.