Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#2,391 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp

调研方向

通过 ExecuteRequestAsync、SendWithRedirectsAsync、HttpClient.SendAsync 和 CstMessageHandler.SendAsync 跟踪 ExecuteAsync,并使用提供的连续请求日志作为复现问题的起始细节。调查围绕 content.LoadIntoBufferAsync 所描述的 .NET Framework 4.8 缓冲和取消路径。当请求不再挂起、取消得到遵守,并且能够到达请求后回调时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug

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
主要语言
C#
星标
9.8k
派生
2.3k
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

restsharp/RestSharp 的其他 Issue

查看 restsharp/RestSharp 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。