C# 中的 httpClient 调用超时,而 cUrl 正在工作 [英] httpClient call in C# goes to timeout, while cUrl is working

查看:60
本文介绍了C# 中的 httpClient 调用超时,而 cUrl 正在工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 httpClient 的奇怪问题.我正在尝试向远程 API 发出 GET 请求.cUrl 在终端上运行良好,但具有相同请求的 httpClient 只会超时.我已经使用 https://curl.olsh.me/ 工具创建了 httpClient并将等待时间设置为 2 分钟.请求被触发后,等待,但没有得到响应码,进入异常

I have a strange problem with httpClient. I am trying to make GET request to remote API. The cUrl is working perfectly from terminal, but the httpClient with the same request, is only going to timeout. I've created the httpClient using https://curl.olsh.me/ tool and set the wait time to 2 minutes. After the request is fired, it waits, but gets no response code, and goes to exception

2021-04-23 03:40:22.686 +01:00 [INF] {httpRequest} 
2021-04-23 03:42:02.798 +01:00 [ERR] Exception Message : The operation has timed out. 

你能猜出什么是问题吗?提前谢谢您

Can you please make any guess what can be a problem. Thank you in advance

推荐答案

感谢所有评论者,尤其是 @jdweng .它让我知道在哪里搜索问题.因此,超时问题是由 TLS 身份验证引起的.未在服务器上导入根证书.导入root证书后,问题解决.

Thanks everyone who commented, especially to @jdweng . It gave me some idea where to search for the problem. So, the timeout problem was caused by TLS authentication. The root sertificates were not imported on server. After importing root sertificates, the problem was solved.

不好的是,无法从异常文本中找出确切的问题.

The bad thing is that it was impossible to figure out the exact problem from an exception text.

这篇关于C# 中的 httpClient 调用超时,而 cUrl 正在工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆