简体   繁体   English

如何检测服务(Web API)是否已断开与HttpClient的连接?

[英]How to detect if the Service(Web API) has lost connection to the HttpClient?

Is there a good way to detect if the service has lost connection to the HTTP client of the current request being processed? 有没有一种好的方法来检测服务是否已断开与正在处理的当前请求的HTTP客户端的连接? My service is built on Web API in C#. 我的服务基于C#中的Web API。

I have observed that the server keeps on waiting for 120 seconds before it raises following exception. 我观察到服务器在引发以下异常之前一直等待120秒。 Where can I configure this setting to wait less? 在哪里可以配置此设置以减少等待时间? "System.Net.HttpListenerException: The I/O operation has been aborted because of either a thread exit or an application request" “ System.Net.HttpListenerException:由于线程退出或应用程序请求,I / O操作已中止”

thx 谢谢

Use the Timeout Property of the object you're using. 使用您正在使用的对象的Timeout属性。

Check this for HttpWebRequest . 检查HttpWebRequest

Check this for HttpClient . 检查HttpClient

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM