Skip to content

ObjectDisposedException / SocketsHttpHandler in .NET 2.1 #27610

@nulltoken

Description

@nulltoken

Hello,

While upgrading our Web application from .NET Core 2.0.9 to 2.1.4, we started to see some ObjectDisposedException popping up (roughly 30 mins after application start), stating that SocketsHttpHandler could no longer be used.

Googling a bit led us to #27327. As this was supposed to fixed in 2.1.5, we decided to wait for it to be released.

Now, running on 2.1.5 we're still experiencing them.

I've trimmed down the project as much as I could into the simplest possible repro case I could come up with.

Steps:

  • Run the app (which should display some proxied json payload)
  • Refresh it regularly
  • Around 25~30mins the following exception happens
System.ObjectDisposedException

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'SocketsHttpHandler'.
   at System.Net.Http.SocketsHttpHandler.CheckDisposed()
   at System.Net.Http.SocketsHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Web.Controllers.HomeController.InvokeSearch() in C:\REDACTED\src\Backend\Controllers\HomeController.cs:line 46
   at Web.Controllers.HomeController.SearchAsync() in C:\REDACTED\src\Backend\Controllers\HomeController.cs:line 23
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtenet-compatibilityIncompatibility with previous versions or .NET Framework

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions