简体   繁体   English

Web服务客户端中止连接

[英]Web Service client aborted connection

How can I know if a client has aborted/closed the connection from the server in a web service. 我如何知道客户端是否已中止/关闭来自Web服务中服务器的连接。 I have an high traffic app and sometimes for intermitent communications my clients are aborting/closing the transactions and I have a positive negative, because I don't know if the client still waiting my response. 我的应用程序流量很大,有时间歇性通信会导致我的客户中止/关闭交易,而我的评价却是负面的,因为我不知道客户是否还在等待我的回复。

My webservice is in C# with framework 4.0 我的Web服务是在C#中使用框架4.0

I need solve this from server. 我需要从服务器解决此问题。

You can't this is how the HTTP protocol works 您不可能是HTTP协议的工作方式

you have to implement your own code to test if the service is up: 您必须实现自己的代码以测试服务是否启动:

How do I test connectivity to an unknown web service in C#? 如何在C#中测试与未知Web服务的连接?



One way you can minimize the problem is to use sessions in your webservice. 最小化问题的一种方法是在Web服务中使用会话。 Of course, this decision may bring other impacts (eg increased consumption of system resources) but will allow you to detect when a session is ended by the client inactivity. 当然,此决定可能会带来其他影响(例如,增加系统资源的消耗),但将使您能够检测到会话何时因客户端不活动而结束。 You will have to do some tests to find a timeout value that best suits your needs. 您将必须进行一些测试才能找到最适合您的超时值。 The link below contains information on configuring Microsoft and consume a webservice using sessions: 以下链接包含有关配置Microsoft以及使用会话使用Web服务的信息:

http://msdn.microsoft.com/en-us/library/ms733040.aspx http://msdn.microsoft.com/en-us/library/ms733040.aspx

I hope it helps. 希望对您有所帮助。 Happy coding! 编码愉快!

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

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