Reputation: 71
I starts my WCF service like this:
host = new ServiceHost(typeof(Host), new Uri("net.tcp://127.0.0.1:40000"));
host.AddServiceEndpoint(typeof(IHost), new NetTcpBinding(), "");
host.Open();
and client app connect to it:
IProxy proxy = new DuplexChannelFactory<IProxy>(callback, new NetTcpBinding(), new EndpointAddress("net.tcp://127.0.0.1:40000")).CreateChannel();
It works fine. I can connect to server and exchange data. Question is how can I start this service(server) so computers from outside my network could connect to it via internet?
Upvotes: 0
Views: 2652
Reputation: 757
You can host it in iis7.It supports net.tcp binding
http://blogs.msdn.com/b/swiss_dpe_team/archive/2008/02/08/iis-7-support-for-non-http-protocols.aspx
Upvotes: 0
Reputation: 475
You need to change the IP address from loopback (127.0.0.1) to your external IP address (find it via www.whatismyip.com).
Then, if you're behind the firewall, you'll need to allow port 40000 through. And if you're behind the router, you'll need to forward port 40000 to your local IP address (open command prompt and type ipconfig - you'll get it there).
After that you'll need to change the client connection string with the external IP address.
Upvotes: 2
Reputation: 101614
Make sure there's no personal firewall, if you're behind a router/proxy, make sure port forwarding is enabled or you set your server as DMZ. If the server has a dynamic IP, it may be a good idea to assign it a static one so a computer restart (for whatever reason) won't mess with the settings at a later date.
Basically, prevent anything that would allow an incoming connection from not seeing the server and the port that's hosting the service. Obviously though, all this comes with certain expectations of security, and making sure you're not making yourself easily victimized. (The key is to allow the bare minimum to get the job done--no more or less).
Upvotes: 0