views:

205

answers:

2

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. 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:

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?

+1  A: 

What version of IIS is your service running on (assuming IIS)? IIS 6 is quite a bit more limited than IIS 7 - it only supports HTTP activation. 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.

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. (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.

Lars Kemmann
I tried running a small peer-to-peer application on Windows Server 2008 R2 (IIS 7.5) and the first error that I got was PNRP was not installed. After fixing that by installing PNRP I got the exact same error. I also got the same error when I tried to host it in my development server on Windows 7.
Ryan Pedersen
I'm running Windows 2008 / IIS 7 with PNRP installed, since it is not by default on Server 2008.
David
Running a Windows Service peer application that communicates with the IIS process sounds interesting, but the whole point is to create some teamwork between IIS servers without adding a lot of extra dependencies. If an extra process is required, I think it would probably make sense at that point to go with a full distributed cache system like Velocity or Memcached.
David
I'm trying to do the exact same thing, and thus ended up here. I'm having an extremely difficult time getting multiple web applications to talk to one another with some sort of broadcast mechanism. I already tried UDP, but that doesn't work property in a web application either.
Brian Vallelunga
A: 

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.

bleevo