Skip to content

Application Hang in waiting/reading response from server under .Net FW 4.8 #2391

Description

@GibChemspeed

Describe the bug
Under .Net Framework 4.8 and after the upgrade from RestSharp v106 to v114 and in a multi-threaded environment, we experience on rare occasions hangs of web requests through RestSahrp

To Reproduce
We have extensively introduced more logging on our client using interceptors and introduced our own custom message handler.

Find below two consecutive requests, the first one completing correctly and the second one did not finish. After SendAsync returns the next message AfterHttpRequest would have been expected but never came.

Request 1

2026-06-03 13:22:08.061 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Get RestClient with identifier: 2474
2026-06-03 13:22:08.062 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Resource: "cst-api/product-management/attributes/get-attribute-values/"
2026-06-03 13:22:08.062 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Request Parameters: [{ContentType:{Value:application/json,AsMediaTypeHeaderValue:{CharSet:null,Parameters:[],MediaType:application/json}},Name:,Value:{OwnerType:3,OwnerId:997,NodeId:null,Category:{Id:72,CstId:null},AttributeDefinitions:[{Id:371,CstId:null}],AttributeFallBackBehavior:{UseArticleFallback:true,UseDefaultArticleFallback:true,UseCategoryFallback:true,UseAttributeDefinitionFallback:true,UseRunAssemblyFallback:false,UseNodeFallback:false,UseWorkflowStepFallback:false,ArticleRoleTypeUsedInDefaultArticleFallback:{Id:0,CstIdentifier:00000000-0000-0000-0000-000000000000,Label:}},Simulated:false},Type:3,Encode:false}]
2026-06-03 13:22:08.062 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Request Body: {OwnerType:3,OwnerId:997,NodeId:null,Category:{Id:72,CstId:null},AttributeDefinitions:[{Id:371,CstId:null}],AttributeFallBackBehavior:{UseArticleFallback:true,UseDefaultArticleFallback:true,UseCategoryFallback:true,UseAttributeDefinitionFallback:true,UseRunAssemblyFallback:false,UseNodeFallback:false,UseWorkflowStepFallback:false,ArticleRoleTypeUsedInDefaultArticleFallback:{Id:0,CstIdentifier:00000000-0000-0000-0000-000000000000,Label:}},Simulated:false}
2026-06-03 13:22:08.063 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - ResilientWebRequestEx
2026-06-03 13:22:08.063 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] >> BeforeRequest 13:22:08.063 | POST cst-api/product-management/attributes/get-attribute-values/ | Parameters: 4
2026-06-03 13:22:08.063 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [RequestBody] : Chemspeed.ServiceLayer.Api.Common.ProductManagement.Attributes.AttributeContext
2026-06-03 13:22:08.064 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Cache-Control: no-cache
2026-06-03 13:22:08.064 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Connection: close
2026-06-03 13:22:08.064 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Authorization: Bearer eyJhbGciOi*****
2026-06-03 13:22:08.065 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] >> BeforeHttpRequest 13:22:08.065 | URI: http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/
2026-06-03 13:22:08.065 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] >> SendAsync to http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/ | ServicePoint connections: 0/20 | IdleSince: 13:22:08.057
2026-06-03 13:22:08.082 [17] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] << SendAsync returned for http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/ | ServicePoint connections: 1/20
2026-06-03 13:22:08.083 [17] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] >> Raw HttpResponseMessage received at 13:22:08.083 | Status: 200
2026-06-03 13:22:08.083 [17] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler]    Content-Length header: -1
2026-06-03 13:22:08.084 [16] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] << AfterHttpRequest 13:22:08.084 | Status: 200 OK
2026-06-03 13:22:08.084 [16] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] << AfterRequest 13:22:08.084 | 200 OK | Status: Completed | Content-Type: application/json | Size: 1259 bytes
2026-06-03 13:22:08.085 [16] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] >> BeforeDeserialization at 13:22:08.085 | Status: 200 | Content-Type: application/json | RawBytes buffered: 1259 bytes | Response body already in memory: True
2026-06-03 13:22:08.085 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Call to Uri succeeded: http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/
RestClient ResponseStatus: Completed, HTTP StatusCode : Description: OK : OK
Data: [{Id:53067,AttributeDefinition:{Id:371,CstIdentifier:a9717272-5f12-4005-a25c-b41edbfaf35c,Label:Located at,Comment:Module ID,ArrayDimension:0,DefaultUnit:2800,UnitLabel:Integer,Measurement:25,CategoryId:null,CategoryCstId:a618a3f0-fedc-4dc5-8c3d-3dad2c0c504c,CategoryLabel:null,DisplayOrder:0,ArchiveMode:0,MinValue:null,MaxValue:null,DefaultValueInfos:[],DefaultValueInfosInSI:[],InitialValueInfos:[],SelectOnly:null,AlwaysEditable:null},Category:{Id:72,Label:Shuttle Attributes,Comment:null,CstId:a618a3f0-fedc-4dc5-8c3d-3dad2c0c504c,AttributeDefinitions:[]},AttributeOwnerType:3,AttributeOwnerTypeName:null,AttributeValues:[{Id:4530072,AttributeId:0,AttributeDefinitionId:null,Value:{Bool:null,Int:14,Double:null,String:null,DateTime:null,File:null,DataType:2},ValueInDisplayUnit:{Bool:null,Int:14,Double:nu

Request 2

2026-06-03 13:22:08.087 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Get RestClient with identifier: 2474
2026-06-03 13:22:08.088 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Resource: "cst-api/product-management/attributes/get-attribute-values/"
2026-06-03 13:22:08.088 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Request Parameters: [{ContentType:{Value:application/json,AsMediaTypeHeaderValue:{CharSet:null,Parameters:[],MediaType:application/json}},Name:,Value:{OwnerType:3,OwnerId:998,NodeId:null,Category:{Id:72,CstId:null},AttributeDefinitions:[{Id:371,CstId:null}],AttributeFallBackBehavior:{UseArticleFallback:true,UseDefaultArticleFallback:true,UseCategoryFallback:true,UseAttributeDefinitionFallback:true,UseRunAssemblyFallback:false,UseNodeFallback:false,UseWorkflowStepFallback:false,ArticleRoleTypeUsedInDefaultArticleFallback:{Id:0,CstIdentifier:00000000-0000-0000-0000-000000000000,Label:}},Simulated:false},Type:3,Encode:false}]
2026-06-03 13:22:08.088 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - Http Request Body: {OwnerType:3,OwnerId:998,NodeId:null,Category:{Id:72,CstId:null},AttributeDefinitions:[{Id:371,CstId:null}],AttributeFallBackBehavior:{UseArticleFallback:true,UseDefaultArticleFallback:true,UseCategoryFallback:true,UseAttributeDefinitionFallback:true,UseRunAssemblyFallback:false,UseNodeFallback:false,UseWorkflowStepFallback:false,ArticleRoleTypeUsedInDefaultArticleFallback:{Id:0,CstIdentifier:00000000-0000-0000-0000-000000000000,Label:}},Simulated:false}
2026-06-03 13:22:08.089 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - ResilientWebRequestEx
2026-06-03 13:22:08.089 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] >> BeforeRequest 13:22:08.089 | POST cst-api/product-management/attributes/get-attribute-values/ | Parameters: 4
2026-06-03 13:22:08.089 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [RequestBody] : Chemspeed.ServiceLayer.Api.Common.ProductManagement.Attributes.AttributeContext
2026-06-03 13:22:08.090 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Cache-Control: no-cache
2026-06-03 13:22:08.090 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Connection: close
2026-06-03 13:22:08.090 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor]    Param [HttpHeader] Authorization: Bearer eyJhbGciOi*****
2026-06-03 13:22:08.091 [9] INFO Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [Interceptor] >> BeforeHttpRequest 13:22:08.091 | URI: http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/
2026-06-03 13:22:08.091 [9] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] >> SendAsync to http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/ | ServicePoint connections: 0/20 | IdleSince: 13:22:08.084
2026-06-03 13:22:08.110 [16] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] << SendAsync returned for http://192.168.135.10/cst-api/product-management/attributes/get-attribute-values/ | ServicePoint connections: 1/20
2026-06-03 13:22:08.110 [16] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler] >> Raw HttpResponseMessage received at 13:22:08.110 | Status: 200
2026-06-03 13:22:08.110 [16] DEBUG Chemspeed.ServiceLayer.Api.Shared.CstRestclient - [CstMessageHandler]    Content-Length header: -1

Expected behavior
No hanging of requests and respecting of cancellation token

Stack trace
Probably here:

ExecuteAsync(request, ct)
└─ ExecuteRequestAsync (creates timeoutCts+linked ct)
└─ OnBeforeRequest / OnBeforeHttpRequest ✅ logged
└─ SendWithRedirectsAsync
└─ HttpClient.SendAsync(msg, ResponseContentRead, ct)
└─ CstMessageHandler.SendAsync ✅ logged ">> SendAsync"
└─ HttpClientHandler.SendAsync → returns after headers
← finally block ✅ logged "<< SendAsync returned"
← CstMessageHandler returns to HttpClient

        ← HttpClient now must buffer chunked body via:
             content.LoadIntoBufferAsync(maxSize, ct)   ← ** HANGS HERE **
                                                        CT not observed on .NET 4.8 legacy stack

← SendWithRedirectsAsync never returns
← OnAfterHttpRequest never called ❌ missing from log
← OnAfterRequest never called ❌ missing from log

Desktop (please complete the following information):

  • OS: Windows 10/11
  • .NET FW 4.8
  • Version 114

Additional context
Only seems to happen since we upgraded from v106, .Net FW 4.8 stayed the same.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions