- Home /
Receiving UDP data from a master server behind a router.
I am writing a networked game with multiple clients connecting to a single server. To improve networking performance, parts of it are written to use UDP sockets to communicate/receive data from the master server. The problem is receiving data. The server tries to send back data but the client never receives it.
My architecture looks like this:
Server: - Non-Unity program hosted on VM instance with fixed host name and all ports open. Not behind NAT.
listens on UDP port 9001
listens on TCP port 9002
Maintains a list of UDP ip/port pairs.
When a new UDP message comes in from 9001, it iterates over its list of ip/port pairs and forwards that packet to the other ports(excluding the original sender).
Client: - Unity game.
listens on open TCP port assigned by OS.
listens on open UDP port assigned by OS.
When the client starts up, it creates a UDP socket connection with an OS assigned port number, it then initiates a TCP request to the server providing auth data as well as the UDP port it would like to communicate on. The server receives that auth data, and records the user's ip address and port number. Once the client is added to the list it should receive new broadcast data from the server but this isn't happening. I've tested it locally and things work fine, it's only remote connections that break.
For what it's worth, I'm running my game behind a router - I'm guessing that's what's causing the problem. What I want to know is, how can I automatically get the router to forward messages to me? How do games like MMOs that run everything on a master server and most likely use UDP handle this? And using TCP is not an option for my use-case, UDP is absolutely critical.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
What's the best approach for creating a secure authorative server? 0 Answers
Need help on LAN server discovery via UDP Broadcast 0 Answers
Unity UDP freezes if disconnected from server 2 Answers
How to make just a simple server to save arrays and vars for a multiplayer? 0 Answers