Im using http://managedupnp.codeplex.com/ API to open up a port using UPNP on my NetGear DG834g ROUTER with the following code..
public void UPNPOpenPort(int port)
{
Services lsServices;
lsServices = Discovery.FindServices("urn:schemas-upnp-org:service:WANPPPConnection:1");
if (lsServices.Count > 0)
using (Service lsService = lsServices[0])
{
try
{
object[] loObj = new object[] { "", port, "TCP", port, "10.0.0.100", true, "Custom Mapping", 0 };
lsService.InvokeAction("AddPortMapping", loObj);
}
catch (Exception loE)
{
MessageBox.Show(
String.Format(
"{0}: HTTPSTATUS: {1}",
loE.Message,
lsService.LastTransportStatus));
}
}
else
{
MessageBox.Show("Doh No Router Found");
return;
}
}
I have a service host with a NetTCP binding with the same port im feeding into the sub routine to set the UPNP forwarding and I can see an active UPNP record on the router configuration. I can see the port is listening on my local machine and other PC’s on my LAN can connect to the port however using an online Port checker it shows as closed, even though the Router says that it should be forwarding to the correct internal IP.
Does anyone have any ideas or am i missing something?
Best Regards,
Christopher Leach
Yes. I performed a factory restore on the router, enabled UPnP, opened the service host and created a forward. It worked.
Even Teredo decided to come online.
Its great to know from a beginners perspective that its not always your codes(your understanding) fault. Sometimes its your hardware.
Thanks,
Christopher Leach