0

I am using a library called Lidgren network that handles all the network part of my application. It uses UDP.

I never had any problem with TCP applications and port forwarding (apache, FTP, SMTP, etc). I did some TCP applications using TCP and I could connect without a problem.

I am making an online game right now and I use UDP for network transmission. I port forwarded it in my router and I have it running. When I use my remote IP Address (190.136.243.40) to connect to it, I can't. When I use loopback (127.0.0.1) I can connect without any kind of problem.

I turned off Windows firewall, I rebooted the computer, but I still can't connect using my remote IP Address.

Here is part of my code:

public static class ServerInfo
{
    static ServerInfo()
    {
        ServerAddress = Dns.GetHostAddresses("leboran.dyndns.org")[0];
    }
    public const short Port = 6483;
    public static IPAddress ServerAddress;
    public const string AppIdentifier = "UnnamedGameNet";
    public static byte[] MagicByte
    {
        get
        {
            return new byte[4] { 0xF1, 0x64, 0x83, 0xC4 };
        }
    }
}

This is the part where I start my server, probably not important:

public void StartServer()
{
    this.listenThread = new Thread(ListenForClients);
    peerConfig = new NetPeerConfiguration(SharedConstants.ServerInfo.AppIdentifier);
    peerConfig.Port = SharedConstants.ServerInfo.Port;
    peerConfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
    peerConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
    peerConfig.ConnectionTimeout = 2144124;
    netServer = new NetServer(peerConfig);
    listenThread.Start();
}

The port I am using is 6483. I am running a Minecraft server at port 25565 and it works perfectly, so it is not a bad configuration on the router

Pacha
  • 1,438
  • 3
  • 23
  • 46

3 Answers3

1

Some computers have multiple ips in fact they all do, what you are probably experiencing is you've bound you app to listen to port 127.0.0.1 rather than 64.323.23.234 or ideally 0.0.0.0 which would bind all your ips. Check to see if peerConfig lets you pick what ip you are binding to the default may be 127.0.0.1

Also could be a problem with a Router. Try making your computer the DMZ or enabling port forwarding.

j_mcnally
  • 6,928
  • 2
  • 31
  • 46
  • The default is 0.0.0.0, I did what you suggested but it is no good. I can paste other parts of the code if you like, but those are the ones that initializes the server – Pacha Sep 27 '12 at 19:38
1

I dont think this is code related.

Your router would need to have the host configured because you are trying to connect directly to the public end of your router from the private side of it.

If you just want to be able to connect to the dyndns address so you dont have to change code you can also alter the windows hosts file.

Michael Christensen
  • 1,768
  • 1
  • 13
  • 11
  • The thing is that I want to distribute my binaries to other people, I used my VPS and I still can't connect. – Pacha Sep 27 '12 at 19:40
  • So distribute your binary with the domain name, but in your local network add the host to your router if you have a router that supports it or modify the windows hosts file on any machine in your local network you wish to conmect from – Michael Christensen Sep 27 '12 at 19:42
  • I tried to connect from a VPS using another network and it still can't connect – Pacha Sep 27 '12 at 19:43
  • You you cant access it publicly either? – Michael Christensen Sep 27 '12 at 19:45
  • No, which is extremely weird. I can connect without any kind of problem on my LAN-connected computers. – Pacha Sep 27 '12 at 19:47
0

Many consumer routers use the source of a packet to determine whether to treat the data as internal or external. Put another way, if you are on your internal network and try to access any of the IP addresses of your router, your router will treat it as being internal (i.e. responding to port 80 with a customization website, most others with no response).

Unfortunately solutions are hard to come by.

Guvante
  • 18,775
  • 1
  • 33
  • 64