C#请求SSE端点超时问题排查求助
SSE流式数据获取问题排查
我已查阅Stack Overflow上的两个相关问题,排除了套接字关闭的问题。尝试从SSE端点流式获取数据时,已参考相关博客添加了必要的apikey请求头,但仍遇到以下异常情况:
- 使用curl命令可正常获取流式数据
- Postman返回200状态码,但无法获取到SSE数据
- 我的C#代码在获取响应前就超时了,通过Fiddler可拦截到200响应;尝试将
await改为.Result或.GetAwaiter().GetResult()均无改善,调整请求头也未解决问题
curl命令(可正常运行)
curl -v http://<ip>:<port>/api/v3/ble/stream/packets -H "apikey: <key>"
我的C#代码
var request = new HttpRequestMessage(HttpMethod.Get, new Uri($"{APIGW_URL}/{streamingEndpoint}")); request.Headers.Add("apikey", APIKEY); request.Headers.Add("Accept", "*/*"); logger.LogInformation("Sending request {method} to {url}:", request.Method, request.RequestUri); HttpResponseMessage response = await client.SendAsync(request); logger.LogInformation("Received response with status code {statusCode} and headers :");
Fiddler拦截到的响应
HTTP/1.1 200 OK Content-Type: application/json Grpc-Metadata-Content-Type: application/grpc Date: Thu, 12 Oct 2023 16:43:00 GMT Transfer-Encoding: chunked
内容的提问来源于stack exchange,提问作者MikeF
相关产品推荐
相关产品推荐

