Using WCF to self-host a service without IIS over the public Internet RRS feed

  • Question

  • Please forgive my limited knowledge of WCF, but I hope my inexperience with this platform simply means that my idea can be implemented and I just haven't learned out how to do it.

    In the simpliest terms, I'd like to write two apps, one running as the master (service) and the other running the client.  The catch is, the master service app needs to run on any basic PC - mostly by people on their home PCs without any hosting or web services configured.  For example, it'll need to run on Vista Home Basic at a residential house on a standard broadband cable modem connection by someone with zero IT knowledge.  A second catch is that each service application should be separate from any other service applications that may also be exposed to the Internet at the same time.  Think of it like a chat room application where one person has the ability to start a chat session on their home PC.  Then, others can connect to that session from the Internet (by using log in information provided by other means - i.e. email, phone, text, etc.) and all can exchange messages.  Someone running only the client can't create the chat session and can only start the client if they have the proper session ID.  As mentioned, if some other person starts the same service application on their home PC with a different session ID, then only those looking for that session will be able to connect and see messages for that session.  There's an infinite number of possibilities for how the PCs running the service application might be configured as far as firewalls and available ports to the Internet, so I assume using a basic HTTP binding is needed? 

    So, the question is, what the best way to implement this...or, can this idea even be accomplished?  It just seems to me that the service application would have no publically available address for the clients to find wthout some sort of server-style configuration.  I looked heavily into the new .NET Services Service Bus, which allows a service endpoint to be exposed on the cloud (and I got it to work in a basic fashion), but it really seems like overkill for what is intended to be a very simple application suite.  I looked at self-hosting configurations and the PeerChannel classes, but I'm not sure they can accomplish what I'm after.

    Of course, the client side implementation should be very straightforward as long as there's a way to expose the service to the Internet.

    Again, sorry about the lack of knowledge.  Maybe (hopefully?) this is a easy thing to accomplish.


    Steve E.
    Friday, October 23, 2009 1:19 AM


All replies

  • Sorry to be annoying...just bumping this up.
    Friday, October 23, 2009 2:53 PM
  • Hi Steve,

    Do you mean establish a wcf service on computer which connected to Internet with modem(don't have static ip)?

    Maybe Dynamic DNS would be helpful, Dynamic DNS could map dynamic ip to a static dns address. Another approach I could think is creating an service deploying on internet server, then both home PC and remote PC consume the service, communicating via the service.

    Monday, October 26, 2009 8:44 AM
  • Hi,

    To expose a wcf service you have to somehow host the servce and expose the wcf on the internet. To let your service behave in a particular way you will also need to configure your serivce through configuration file or programmatically in your code.

    To your second catch, I think you might need to look at this sample code and get the idea to achieve what you want:


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, October 26, 2009 10:14 AM
  • Thanks for the replies everyone.


    I happened to find that project yesterday while continuing to try and learn about WCF and accomplish my current task.  Thanks for letting me know it's something I should look more heavily into.

    The code for that application is helpful for building a multicast-style (or duplex) application.  This application does work on my internal network.  I can run multiple instances on multiple computers and get them all communicating as designed.  However, I'm not sure it would work between computers over the internet.  I have only had time to test within an internal network.  This is in regards to my first issue...You mentioned "host the service and expose the WCF on the internet".  How would I configure the chat application's chat service to be exposed to the internet so that another computer, somewhere off in the cloud, can start the same chat application (with the proper credentials, of course) and connect?  Remember, this would all have to be running on basic home PCs behind standard, commercially available cable/DSL modems.  Can I accomplish that?

    I'm really looking into PNRP and the WCF PeerChannel classes right now.  It seems that I could write a similar application to that WCFChat, but use the PeerChannel classes instead to create the service/client objects and connect that way.  The IPv6 functionality (which is tunneled through IPv4 and MS servers), looks like it does exactly what I want (connecting individual devices over the Internet).

    Does anyone have any experience with PNRP and PeerChannel?

    Tuesday, October 27, 2009 7:50 PM
  • Hi,

    See this code project sample for how PNRP and PeerChannel works:


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bin-ze Zhao Friday, October 30, 2009 2:43 AM
    Wednesday, October 28, 2009 3:29 AM