NIH alert! Writing my own RPC systems
Let us see if you can help me here, I found myself facing a rather unpleasant realization, in that I need to communicate between two processes (that compose a single system) with some rather draconian measures about how they are going to be used.
Quite simply, I need to expose an interface with ~25 methods on it to the second process. So far, it is pretty easy to do, right?
The problem is that the first process is a standard .NET executable, which may also be run on the Mono platform while the second is a Silverlight application. My first thought, just use remoting to handle this, failed because remoting isn’t available to Silverlight. My second thought, to use WCF, failed because that isn’t available on Mono.
Building a simple RPC system is pretty easy, so that doesn’t worry me. The reason I am reluctant to do so is that I really don’t want to build yet another infrastructure. At some point, even to me, NIH flag starts to pop up.
Comments
Can you pick the Mono version? 2.6 has the WCF stack from Silverlight, IIRC.
And that is why I love this blog :-)
Thanks, I'll check this out
I thought you used ProtocolBuffers in UberProf - can you use that to send messages between processes instead of RPC?
well, the simplest way to do this if you can use the mono version with WCF support is Agatha :)
Rich,
I am using it there, but I use it as data stream, not RPC.
For RPC, you would need to handle a lot of things, such as error handling, method invocation, etc.
Re the protocol buffers / RPC discussion; protobuf-net has a basic RPC stack built in using HTTP, covering those error-handling, method-invocation, etc issues. I honestly haven't tried it between Silverlight and Mono, so I can't guarantee that it'll work. If you're on a framework with Expression, it allows usage like:
Without Expression it is a bit less pretty.
Sounds like a good spot for a plug.
You can use Service Stack ( http://www.servicestack.net) - an opensource XML/JSON/REST web services framework that runs on .NET or Mono which can be hosted in IIS, XSP or even inside a standalone console app (which uses HttpListener behind the scenes).
This link below shows a live 'silverlight client' talking to XML services hosted on CentOS/Nginx server:
www.servicestack.net/.../Silverlight.htm
For a quick overview on servicestack here's an in-depth tutorial creating and calling mono webservices from a MonoTouch client (C# on iPhone):
http://www.servicestack.net/monotouch/remote-info/
Dennis,
I'll look at that. My issue with HttpListener is that it requires admin privileges
Marc,
What implementation are you talking about?
On second thought, Demis, I checked out the license, and it is GPL, which mean that I pretty much can't make any use of it
@Ayende
Yeah admin rights is a problem with HttpListener. This is where the other options may be more appropriate. On the upside HttpListener allows you to host on the same port at the same time with IIS.
Just sent you an email - I'm happy to change it to a more appropriate licence if needed.
@Ayende - I don't fully understand the question, but note that the current server implementation uses HttpListener, so if that is a problem... But I'm on about the RPC stack in protobuf-net; examples are in the unit-test project - see the HttpWithLambda test-fixture here: code.google.com/.../HttpBasic.cs
Marc,
I need to run it as non admin user
Is the Mono server on linux? On Windows you don't actually need to be admin to use HttpListener - you just need the port opened for http.sys (via netsh etc). Is there maybe something similar for linux?
Marc,
I know, but that step is an extra one that I really don't want to do
Ayende,
I am a little bit confused here. What do you mean but the extra one step that you are talking about. I thought it just be same for both?
I mean that it is an extra step in the install process
Have you looked at Thrift?
Maybe a web server assembly should be used? http://www.codeplex.com/webserver
Bit excessive though.
Why you dont create a simple ProtocolBuffers based message bus and send messages over it instead of doing RPC?
Steve,
I need request / reply, not pub/sub
But you could block the execution until a reply message was received.
So I am building RPC on top of pub/sub?
What does this give me?
It solves you problem without needing to have an external technology which is may not implemented in another platform. It also could work if java is on one of both sides.
The actual serialization format isn't what worries me.
@Frans,
Thanks you for defining someone a "daredevil", it makes me feel younger. Less polite is the "big mounth",but I know, is the price we have to pay for you sharing your wisdom. but is Actually the 'personal' contrib version i'm talking about is on the offical contrib version. I do not have so much useless time to spent, this is the reason my work is for sure a little monkey in comparison to your. I just did it cause NH give me a lot of productivity and I would like to pay back something. Basically I'm really surprised on seeing so many people complaining for documentation, the site NHForge is plain of whatever you need to starup with NH. Plus you have the source code. Plus you have a lot of people helping you basically for free ( Fabio Maulo one of the best,Ayende as well). Furthermore, the fancy designer with fancy colored boxes is a "must have" that fail as soon the model pass the 15 entities...
I'm sure you thought of this, but if you have a moment can you explain why a separate proxy layer/service/wrapper that translates between Remoting and WCF is not a good option?
Because I initially thought that WCF is completely not an option
Have you considered using some RESTful services ? (I'm not sure of ASP.Net MVC's compatibility with Mono but it could be a good start)
You may also find some interesting keys with json services (with JSON.Net for example)
Comment preview