Re: Easy UPnP NAT Traversal
Oh yes: Tested on XP, Vista, and Windows 7.
And the "ping numbers" are just random numbers sent as "ping" text for argument's sake (and uniqueness).
Re: Easy UPnP NAT Traversal
Hmm, I went back and looked at my notes on the other approach and it seems I had known about this and tried it. It looks like it was unreliable though. Perhaps I wasn't using it right before or I'm just "lucky" this time around.
Perhaps somebody else can shed some light on this. The notes I retained aren't detailed and I'm no longer sure where I got in trouble before using this approach.
Sure seems to be working now though!
Re: Easy UPnP NAT Traversal
When I clicked Add, it says error 'Object Variable Or with Block Variable Not set' at line Set StaticPortMapping = UPnPNAT.StaticPortMappingCollection.Add(CLng(txtExtPort.Text), _
"TCP", _
CLng(txtIntPort.Text), _
Winsock.LocalIP, _
True, _
"FAS")
I am using Windows 7 64-Bit.The projetc reference is set to c:\Windows\system32\hnetcfg.dll\2.
I login to internet using WAN Miniport PPPOE.If the Router/Gateway does not support UPnP does this Error raise?. The error displayed in your program is "Add failed, error 0000005B".
Re: Easy UPnP NAT Traversal
When I clicked Add, it says error 'Object Variable Or with Block Variable Not set' at line
Code:
Set StaticPortMapping = UPnPNAT.StaticPortMappingCollection.Add(CLng(txtExtPort.Text), _
"TCP", _
CLng(txtIntPort.Text), _
Winsock.LocalIP, _
True, _
"FAS")
I am using Windows 7 64-Bit.The projetc reference is set to c:\Windows\system32\hnetcfg.dll\2.
I login to internet using WAN Miniport PPPOE.If the Router/Gateway does not support UPnP does this Error raise?. The error displayed in your program is "Add failed, error 0000005B".[/QUOTE]
Re: Easy UPnP NAT Traversal
Quote:
Originally Posted by
tonydsouza1987
When I clicked Add, it says error 'Object Variable Or with Block Variable Not set' at line
Code:
Set StaticPortMapping = UPnPNAT.StaticPortMappingCollection.Add(CLng(txtExtPort.Text), _
"TCP", _
CLng(txtIntPort.Text), _
Winsock.LocalIP, _
True, _
"FAS")
I am using Windows 7 64-Bit.The projetc reference is set to c:\Windows\system32\hnetcfg.dll\2.
I login to internet using WAN Miniport PPPOE.If the Router/Gateway does not support UPnP does this Error raise?. The error displayed in your program is "Add failed, error 0000005B".
Error &H5B (91) is the same exception as "Object Variable Or with Block Variable Not set."
Yes, this exception is raised if UPnP is unsupported or turned off at the router. You might also see it if a firewall is blocking UPnP traffic.
Re: Easy UPnP NAT Traversal
Thanks for your reply.....
I have allowed the following programs in Firewall :
- Network Discovery
- Windows Live Communications Platform(SSDP)
- Windows Live communications Platform(UPnP)
- Routing and Remote Access
I have also turned On 'Network Discovery' on home and public networks.
Still the same error.
The thing is I want VB client to connect my SQL Server from outside the network.So the solution is I need to manually Port Forward on router right??
By the way how this UTorrent works on my PC?How my PC gets Incoming connections routed Via Utorrent?
Within my LAN Network VB Client connects to SQL Server, Outside it doesnt.
Any other soultion for this to work from outside my LAN Network?I dont have access(username/pwd) to my Mikrotik router.So I htought I would use your code and port forward on router.. This doesnt work...
Re: Easy UPnP NAT Traversal
Network Discovery is the one you need opened up.
If your router has UPnP disabled this code won't help. You'd need access to turn it on or to manually map the required ports inbound to your SQL Server instance (default is TCP 1433).
I won't comment on the morality of most uses of BitTorrent clients, but yours probably uses a "hole punching" technique not easily achieved using VB.
Re: Easy UPnP NAT Traversal
OK, here's the deal. My home network is set up like this: Internet->Verizon router->wireless router. When I run the program it says Add successful. Then I try Ping but nothing happens. Then I remove and it says Remove successful. But the weirdest thing is that for external IP it shows the ip of my wireless router, not my actual external ip!! What do I do? Also the firewall on my pc is disabled if anything)
Re: Easy UPnP NAT Traversal
Why do you have a NAT router behind a NAT router though? That's pretty... strange.
In your case you should be using a wireless access point, not a router. Can you disable the routing in this wireless device to make it work as a pass-through access point?
If so then it becomes a question of whether or not the Verison router accepts UPnP configuration. if not there isn't anything you can do.
Re: Easy UPnP NAT Traversal
Yeah I figured that would be the best way. I just have this setup cause verizon router didn't have wireless.
Thanks for the advice.
Re: Easy UPnP NAT Traversal
Those home "wireless router" devices are sold at high volume so they are cheap even though they incorporate about three network devices in one: a router, a switch, and a wireless bridge/access point.
What you really need in your case is a separate wireless access point device. These aren't as popular though so they tend to cost as much as (or more than) a consumer wireless router, but they can be found for about the same price if you shop around.
Cisco, Linksys, D-Link, ZyXEL, and TrendNET are just a few of the brands that you can find out there.
You need to know what you're buying though.
Re: Easy UPnP NAT Traversal
Also, have you tried udp hole punching? I don't understand why there are no examples of it anywhere...
Re: Easy UPnP NAT Traversal
I don't think hole-punching techniques can be done in VB without the help of a public server.
Even then it probably won't work if you have totem-poled multiple NAT routers. You are not supposed to do that.
Re: Easy UPnP NAT Traversal
dilettante;
I know this post is old, but it intrigues me. It actually adds the port forwarding and returns the external IP. But when I try to remove the port forward, it returns Error 80070002. There is not a whole lot of info available on this error, and the closest I can come to it is:
System.IO.FileNotFoundException
Any ideas?
J.A. Coutts
Re: Easy UPnP NAT Traversal
Well 0x80070002 is ERROR_FILE_NOT_FOUND. But I suspect this error code is being used in a broad, generic sense. What it probably means is that access for that action was denied by your router.
I just tried the sample program without even recompiling it, as a standard user. Works just fine and this is on a newer OS with a different router than I was using back then.
Re: Easy UPnP NAT Traversal
Quote:
Originally Posted by
dilettante
Well 0x80070002 is ERROR_FILE_NOT_FOUND. But I suspect this error code is being used in a broad, generic sense. What it probably means is that access for that action was denied by your router.
That's kinda the conclusion I came to as well, although I have no way of verifying it. I have had very little success at getting any of the other API calls to work. I was hoping to use this control to recover the external IP address, but I have given up and found another way.
J.A. Coutts