Link to home
Start Free TrialLog in
Avatar of veepware
veepware

asked on

How to solve the client/server connection issue behind a router?

I wrote two applications, client and server using Visual C++ 2008. When I try to connect them they work fine in LAN network using local IP address like: 192.168.1.2 for the client and 192.168.1.3 for the server.

The problem is that when they connect over the internet, say for example the client is in a city and the server is in another city and both are behind routers they DO NOT connect even I use the public IP.

 What I know is that the router clients all use one public IP to share internet connection, and the router generate  local IPs for them.
I asked many developers but I had no clear answer, they suggest to disable NAT function of the router or put a redirect port. Then I  responded why MSN for example did not need this kind of configuration to work where multiple users can connect under the same public ip behind a router?

If you know a technique, a website, a resource to solve this problem. Please share it with me I'm waiting...
Avatar of ericathome
ericathome
Flag of United States of America image

When you say client/server, in addition to making sure routers are established on both sides of the router connection (assuming a VPN pair since detail not provided), you need to make sure the ports used by client and server traffic are carried across the router connection. Check the routing tables and the filters on your routers as a beginning to troubleshooting. Do make sure you are using a secure connection such as PPTP in connecting the two routers across the Internet.

See below for some resources on the topic:

DNS Troubleshooting made easy: https://www.experts-exchange.com/articles/Networking/Protocols/DNS/DNS-Troubleshooting-made-easy.html

Building A WCF Router, Part 2: http://msdn.microsoft.com/en-us/magazine/cc546553.aspx

How to Configure a FREE Hardward PPTP VPN Using a DD-WRT Compatible Router: https://www.experts-exchange.com/articles/Software/System_Utilities/Remote_Access/VPN/How-to-Configure-a-FREE-Hardward-PPTP-VPN-Using-a-DD-WRT-Compatible-Router.html

Let me know how it goes and provide additional detail if you need additional ideas. Thanks, Eric
Avatar of Mike_Mozhaev
Mike_Mozhaev

If you are behind a router it's the router that has your public IP. But your application is not on the router but on a computer behind it. To deal with such situation you'll need to set up port forwarding on your routing.
Simply put port forwarding is the way to specify path from internet to some computer in local network.
E.g. we can redirect all packets coming to port A on router (i.e. your public IP) to port B on 192.168.1.2
Using different external ports we can route traffic to different computers inside LAN.
For more details search for info about NAT (network address translation) and port fowarding.
Avatar of AndyAinscow
Is a firewall active and preventing connection ?
Avatar of veepware

ASKER

Thanks for all of you. But I don't want to touch the router (in other words: NO HARDWARE, but if programmatically then no problem). OK let's go one more time with some extra details.

The clients sends a request (command) to the server, the server however is found on another network.

To clarify things, take the example of  Windows Live Messenger: When I install; it I don't need to touch the router or put any forward port from my part. If I can do it programmatically that it is fine. I attached a diagram on how things are going.

I hope things are clear now,  please feel free to request any extra details to solve this issue.

149mc7l.jpg
For request-response communication no port forwarding is required since server has address which is visible from outside and routing the response back to client is performed transparently by NAT.
But if you want to use some king of events then your server acts as a client and hence it needs a route to client and this is done by port forwarding.
ASKER CERTIFIED SOLUTION
Avatar of ericathome
ericathome
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ericathome, your response help me a lot, Thank you. I accept your answer as a solution.