6
\$\begingroup\$

I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines. I checked my port when running the server, and it says it's closed, despite the lidgren server running. I set the NetPeerConfiguration localaddress to be my ipv4 address and made sure my router was forwarded at this ipv4 address at the port I was running the server on, but still no luck. Here is the relevant server code-

NetPeerConfiguration config = new NetPeerConfiguration("Platformer");
IPAddress[] ipv4Addresses = Array.FindAll(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork);
config.LocalAddress = ipv4Addresses[0];
config.Port = 8888;
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
NetServer server = new NetServer(config);
server.Start();

The server says it's being started at the local ip with the right port, and everything is forwarded correctly on the router. What is going wrong here?

\$\endgroup\$
6
  • \$\begingroup\$ It will work if I run the server and the game on the same machine, so it will connect locally but not on an external server because the server isn't running properly. The port is closed whenever I check it when running the server. \$\endgroup\$ Jul 15 '15 at 6:05
  • \$\begingroup\$ How would I open this port by myself then? \$\endgroup\$ Jul 15 '15 at 6:33
  • \$\begingroup\$ I am able to start a TCPListener on this port with no problem... however it is only Lidgren giving me issues with this. I believe it is something to do with the fact that it is UDP? Still, it doesn't make any sense because it's forwarded for both TCP and UDP, and the TCPListener opens the port perfectly. \$\endgroup\$ Jul 15 '15 at 7:29
  • 2
    \$\begingroup\$ Post your client connection code. Are you still using the localhost? Also, disregard what Shiro is saying. \$\endgroup\$
    – jgallant
    Jul 15 '15 at 10:07
  • 1
    \$\begingroup\$ Why would the client connection code matter if the issue is that the Lidgren server isn't opening the port to begin with? \$\endgroup\$ Jul 15 '15 at 10:11
0
\$\begingroup\$

You say you have checked your ports, but have you opened them first?

Find your Router portforward.com and add a rule for port 8888 (The port the server is listening on) if there is an option for TCP / UDP, choose UDP.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .