DevPinoy.org
A Filipino Developers Community
   
WCF: Shifting from HTTP to TCP

We've decided to shift our project's WCF services from HTTP to TCP.

Why? We've got a few reasons:

  • Performance is important. We all know the TCP-based protocol (used by NetTcpBinding) is faster and has lower latency than the HTTP-based protocol (BasicHttpBinding and WsDualHttpBinding).
  • The system was initially envisioned to have its services available to other platforms (even non-.NET). This meant .NET Remoting was out of the picture, and we had to go with web standards. It turns out that this was YAGNI, as no system needed or wanted to connect to ours Stick out tongue. So given that the original reason for going with an HTTP-based binding proved to be a dud, there's no reason for us to stay with it.
  • We use WCF callbacks, and in order to support that feature with an HTTP-based protocol, we had to settle with WsDualHttpBinding. That meant the client had to act as a server, with the server establishing a reverse connection to the client for callbacks. Our engineering team didn't like it, saying it can potentially be a nightmare, administration- and security-wise. With NetTcpBinding, we get the benefit of bidirectional communication between client and server without the need for a reverse connection with the client also acting as a server.

The only problem with going with a TCP-based protocol is that we will not be able to host our service using IIS. We could not migrate to Windows Server 2008 and IIS 7.0 at this time, so that means we will have to create our own Windows service to act as our service host. This single downside is pretty minor, don't you think?

It was a pleasant surprise that with WCF all it took to shift to the TCP-based protocol was to change the app.config file! Everything worked as well as it did when we were still using BasicHttpBinding and WsDualHttpBinding...no recompile necessary. To me this is a clear win over the old ASMX web service/.NET remoting divide with .NET 2.0 and older framework versions. It's so easy to change protocols and bindings -- without WCF, porting between web services and .NET remoting was non-trivial and certain to introduce side effects. Yes

 


Posted 11-01-2008 4:23 PM by cruizer
Copyright DevPinoy 2005-2008