WCF Service behind firewall – How to set up port forwarding?
Asked Answered
F

2

1

I'm just getting into WCF programming. I've set up a self-hosted test web service on my work computer, which is behind a firewall; it's at http://localhost:8000/MyTestService. I can access the service page through the browser; all working fine.

Now I want to access that service from my home computer, which is on a different network. I have a dynamic dns (call it mydomain.dyndns.org) set up to point to my work router. Have tested, dyndns is pointing to the right address.

Now I have installed a test app on my home computer to connect to my web service. So I configured my NAT for forward requests on port 8000 to my work computer, on the same port number.

On my home computer I now open a browser and navigate to http://mydomain.dyndns.org:8000/MyTestService. Nothing doing.

Obviously I'm missing something really fundamental about NATs and port forwarding... but as I say, I'm kinda new at this aspect of programming, and I'd really appreciate some guidance here!

Frock answered 24/12, 2010 at 10:55 Comment(0)
B
4

Do you see an error or an empty page? Can you check canyouseeme.org from the computer behind the firewall that the port is really open? Can you check with tools like sysinternals tcpview that the connection attempt reaches this computer and not just the router?

Bores answered 24/12, 2010 at 10:59 Comment(3)
You need 3 things: a port forwarding, an open port on the router, and an open port on your computer. You might need to open the port on the router's firewall in addition to adding a port forward. It's also possible that your computer's firewall doesn't accept incoming connections from outside, only on localhost.Bores
Aha, here's a clue: canyouseeme.org cannot see that port! I tried port 8000 and port 18000, forwarding to my port 8000 on my computer; both failed. The RDP port (3389) does work, though. And when I set up another port (13389) to forward to my port 3389, that also works. So obviously my port 8000 on my computer is not responding properly. Now what?Frock
Opened the firewall on my computer to port 8000 - working now! THANK YOU!Frock
A
2

I had the same problem.

after a good help from this toppic. http://www.codeproject.com/Questions/140317/WCF-services-and-Windows-Firewall. My WCF Service worked well on the local LAN even with the firewall active.

But it was not accessible over the internet. After port forwarding i could see the service description. but I couldn't use it.

This article http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/ points me in the right direction. The service is visible, but connections to your web server will fail because the WSDL is pointing to the non-published server name and your client won’t be able to get there.

In my case a I need to change the self hosted wcf the local endpoint to the public one.

        // 1 Create a URI to serve as the base address.
        Uri baseAddress = new Uri("http://publicdomain.com:8000/GettingStarted/");
        // Step 2 Create a ServiceHost instance
        ServiceHost selfHostRemote = new ServiceHost(typeof(MyService), baseAddress);
Advert answered 22/2, 2013 at 15:8 Comment(1)
This was my issue as well, the uri needs to be that of the physical location where it runs. Thanks Marcel..Alexander

© 2022 - 2024 — McMap. All rights reserved.