UDP API Definition: Difference between revisions

(nat and minor stuff)
Line 96: Line 96:
The local port may be hardcoded, however, an option to manually specify another port should be offered. The servername and port should not be hardcoded into a frontend but should be read from a configuration file.
The local port may be hardcoded, however, an option to manually specify another port should be offered. The servername and port should not be hardcoded into a frontend but should be read from a configuration file.


Note when behind a [http://en.wikipedia.org/wiki/Network_address_translation nat] router:
Note when behind a [http://en.wikipedia.org/wiki/Network_address_translation NAT]/masquerading router:
A session between the server and a client is identified by the ip and port used by the client. So when the port (or ip) changes under a session the client has to authenticate again. If a client is behind a nat router it can’t actually control the local port used. The router will normally translate the port to support several computers on a lan. The public port (as seen by the server and set by the router) will change from time to time, usually after a fixed timeout period (like 5 minutes). So if the client wants to keep a session alive it has to ping the server within this period.
A session between the server and a client is identified by the ip and port used by the client. So when the port (or ip) changes within a session the client has to authenticate again. If a client is behind a nat router it can’t actually control the local port used for the connection. The router will normally translate the port to support several computers on a lan to share the internet connection. The public port (as determined by the router and seen by the server) which has been assigned to the connection will only be reserved for as long as it is in use. This means that the router will usually deallocate the port after a fixed timeout period (i.e. 5, 10 or 15 minutes). Once that happens the client will no longer be able to receive UDP messages from the server (the messages will be discarded as undeliverable by the router) and a new port will be selected once the client tries to send a message to the server (which will result in a new connection session - NOTE: this could get you banned!, see above).
The client can decide whether it is behind a router or not by adding ‘nat=1’ to the AUTH command. (This will cause the response to include used ip and port.)
So in order to keep a session over a NAT router alive, the client has to ping the server within this period to prevent a timeout.
 
The client can decide whether it is behind a NAT router or not by adding ‘nat=1’ to the AUTH command. This will cause the response to include the ip and port as seen by the server. If the port differs from the port reported by the local socket, the connection subject to NAT and the client should issue PING commands in regular intervals.
Please do not send pings more often then once every 5 minutes and only on connections via NAT routers or if the user has explicitly enabled regular keepalive pings via a configuration setting (default setting should be OFF).


=== Flood Protection ===
=== Flood Protection ===
MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.