简体   繁体   English

不能在ASP.NET中使用WCF NetPeerTcpBinding?

[英]Can't use WCF NetPeerTcpBinding in ASP.NET?

I write applications for web farms and I wanted to create a simple peer network between server applications so they could pass messages to each other. 我为Web场编写应用程序,我想在服务器应用程序之间创建一个简单的对等网络,以便它们可以彼此传递消息。 For example, to coordinate when dropping cache items, or to increment a shared counter to have a better shared view of a crucial statistic. 例如,在删除缓存项时进行协调,或增加共享计数器以更好地共享关键统计信息。

But apparently this isn't possible. 但这显然是不可能的。 I had peer-to-peer code working perfectly in a console application, but when I added the code to an ASP.NET website I got the following error: 我的对等代码在控制台应用程序中运行良好,但是当我将代码添加到ASP.NET网站时,出现以下错误:

System event notifications are not supported under the current context. 当前上下文不支持系统事件通知。 Server processes, for example, may not support global system event notifications. 例如,服务器进程可能不支持全局系统事件通知。

[InvalidOperationException: System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10259418
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +539
   // My code here where I call the proxy object's method to start the WCF call

Um, why not? 嗯,为什么不呢? It seems like this would be supremely useful! 看来这将非常有用!

Is there any way to get around this? 有什么办法可以解决这个问题?

What version of IIS is your service running on (assuming IIS)? 您的服务在哪个版本的IIS上运行(假设使用IIS)? IIS 6 is quite a bit more limited than IIS 7 - it only supports HTTP activation. IIS 6比IIS 7有更多限制-它仅支持HTTP激活。 Likewise, if you're trying to start a peer-to-peer client from within IIS 6, it may be blocked for the same reason - IIS can't direct responses to the correct worker process. 同样,如果您尝试从IIS 6中启动对等客户端,则由于相同的原因,该客户端可能会被阻止-IIS无法将响应定向到正确的工作进程。

You could always implement the service as a Windows service on the web server, and use named pipes to communicate with your ASP.NET site. 您始终可以将服务实现为Web服务器上的Windows服务,并使用命名管道与ASP.NET站点进行通信。 (The Windows service would host a peer-to-peer endpoint and a named-pipe endpoint, and the site would use a named-pipe client. The service would run as a single instance using the [ServiceBehavior] attribute. (Windows服务将承载对等终结点和命名管道终结点,并且站点将使用命名管道客户端。该服务将使用[ServiceBehavior]属性作为单个实例运行。

I am not sure this is possible because of the way the binding holds its context. 由于绑定保持其上下文的方式,我不确定这是否可能。

I would suggest having a normal http wcf service and register each host in a configuration database, or even use a topic and post events that web server needs to process. 我建议使用普通的http wcf服务,并在配置数据库中注册每个主机,甚至使用主题并发布Web服务器需要处理的事件。

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

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