JP_
JP_

Reputation: 1666

Unable to connect to local machine IP address using internet IP address

I've spent the last month writing a multiplayer game. I have only been testing it on one machine, using 127.0.01:9051 as the IPEndPoint.

I changed the IP address to my WAN IP, configured port forwarding on my router, configured my software firewall etc... But, it doesn't connect.

I have checked if the port is open using this site. Result: the port is really open.

Also, when I check the port from that website, my server receives packets just fine; however, when I connect from my own machine... it doesn't receive anything.

I've broken everything down to the basics to make sure it wasn't a problem with my code.

This basic code does not work:

IPEndPoint iep = new IPEndPoint(IPAddress.Parse("XXX.XXX.XXX.XXX"), 9051);
TcpClient client = new TcpClient();
client.Connect(iep);

Any ideas are much appreciated.

Upvotes: 2

Views: 1640

Answers (4)

Erik Philips
Erik Philips

Reputation: 54628

If you are attempting to connect to the IP that is Forwarded (outsideIP) to the same machine (insideIP), it won't work. There are very few enterprise firewalls and no consumer devices (I know of) that will route a packet from the inside out and translate it back in.

[Internet] -- outsideIP[Router/Firewall]insideIP1 -- insideIP2[Computer]

In this case, packets from insideIP(X) will not be able to connect to outsideIP.

Upvotes: 3

Wolf5370
Wolf5370

Reputation: 1374

Is your client and your server (both the same machine in your failing test) using the same endpoint ip/port? You can only bind a port once at a time. Try using two ports one for server in one for server out (clinet in). That way they will not clash. Use Telnet to check you can connect to the IP/Ports you are using and Netstat to check they are not in use already.

Upvotes: 0

cdonner
cdonner

Reputation: 37668

You could use Dyndns or some other service for the outside world to connect to your server and put the same name into your host file that resolves to 127.0.0.1 so that you can connect internally.

Upvotes: 0

Ben
Ben

Reputation: 1

Try to see if you can telnet to your wan IP on port 9051. Routers don't really like it when you connect to their wan IP from within the network itself.

Upvotes: 0

Related Questions