关闭 WCF 代理 [英] closing WCF proxy

查看:24
本文介绍了关闭 WCF 代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当涉及到 WCF 代理时,我一直遵循 try/Close/catch/Abort 的指导.我现在面临一个代码库,它在 MVC 控制器中创建代理并让它们超出范围.我认为我们需要编辑代码库以使用 try/Close/catch/Abort 但存在阻力的情况.

I have always followed the guidance of try/Close/catch/Abort when it comes to a WCF proxy. I am facing a code base now that creates proxies in MVC controllers and just lets them go out of scope. I'm arguing the case that we need to edit the code base to use try/Close/catch/Abort but there is resistance.

有没有人知道我可以捕获的指标(例如 perfmon)来说明问题/好处.或者是一份明确的参考资料,阐明了没有人可以质疑的问题/好处?

Does anyone know a metric (e.g. perfmon) I can capture to illustrate the problem/benefit. Or a definitive reference that spells out the problem/benefit no one can dispute?

推荐答案

您可以创建一个示例应用程序来模拟问题.虽然我没试过你可以试试这个,

You can create a sample application to mimic the problem. Though I haven't tried you can try this,

  1. 创建一个简单的服务并将 maxConcurrentCallsmaxConcurrentSessions 限制为 5.

创建一个客户端应用程序,然后在不关闭连接的情况下调用服务方法.

Create a client application and in that, call the service method without closing the connection.

启动 6 个或更多客户端

Fire up 6 or more clients

看看当您从客户端打开一个新连接时会发生什么.可能客户端会等待一段时间,你会得到一些例外.

See what happens when you open a new connection from a client. Probably the client will wait for certain time and you get some exception.

如果客户端没有正确关闭连接,该连接仍将在服务中保持打开状态,那么如果一次有 1000 多个客户端连接到该服务并保持其连接处于打开状态,会发生什么情况?该服务有一个限制,即它一次只能处理n"个连接,因此该服务无法处理来自客户端的任何新请求,这就是关闭连接非常重要的原因.

If the client don't close the connection properly, the connection will still remain open in the service so what happens if 1000s of client connected to the service at a time and leave their connections open? The service has a limitation that it could server 'n' connections at a time and because of that the service can't handle any new requests from clients and that's why closing connections are very important.

我认为您了解 使用 WCF 服务中的问题.在我的应用程序中,我使用扩展方法关闭 WCF 连接,如该 线程.

这篇关于关闭 WCF 代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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