Application Hang in waiting/reading response from server under .Net FW 4.8
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- csharp
调研方向
通过 ExecuteRequestAsync、SendWithRedirectsAsync、HttpClient.SendAsync 和 CstMessageHandler.SendAsync 跟踪 ExecuteAsync,并使用提供的连续请求日志作为复现问题的起始细节。调查围绕 content.LoadIntoBufferAsync 所描述的 .NET Framework 4.8 缓冲和取消路径。当请求不再挂起、取消得到遵守,并且能够到达请求后回调时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- C#
- 星标
- 9.8k
- 派生
- 2.3k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
restsharp/RestSharp 的其他 Issue
-
RestClientOptions.UserAgent missing from requests with useClientFactory: true可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
-
Expose HTTP response trailers on RestResponse可能已有人在做 @Benziza 于 7 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 68/100
-
RestClient configured with Newtonsoft.Json serializer still instantiates System.Text.Json可能已有人在做 @JiuYue0820 于 49 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 65/100
-
delete 940未关闭
难度 1/5 1 小时以内 新手友好度 35/100
-
js/calculator.js未关闭
难度 5/5 一周以上 新手友好度 10/100
查看 restsharp/RestSharp 的全部 Issue
相似的 Issue
-
subsystem: UI
难度 2/5 1-3 小时 新手友好度 82/100
Open-Systems-Pharmacology/PK-Sim#3812 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
PCL-Community/PCL-CE#3652 ·
维护者通常 1 天内回复
-
bug effort:S P3
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#2012 ·
维护者通常 1 天内回复
-
area:frontend bug FE P3
难度 2/5 1-3 小时 新手友好度 68/100
klasolsson81/jobbliggaren#2010 ·
维护者通常 1 天内回复
-
agentic-workflows untriaged
难度 1/5 1 小时以内 新手友好度 65/100
维护者通常 1 天内回复