@@ -89,7 +89,7 @@ The function will return the response in string format from the server, formatte
8989
9090.. note ::
9191
92- You can disable the authentication check by passing 'no_auth=True' to the command function, which will disable
92+ You can disable the authentication check by passing 'no_auth=True' to the command function, which will disable
9393 the check for this command. Be aware that if the server refuses to serve you, then a RCONAuthenticationError
9494 exception will be raised.
9595
@@ -108,17 +108,58 @@ The command sent will broadcast "Hello RCON!" to every player on the server.
108108 when issued over RCON, so this is usually a normal operation. It can also mean that the server doesn't understand
109109 the command issued.
110110
111- RCON Packet Fragmentation
112- _________________________
111+ RCON Outgoing Packet length
112+ ___________________________
113113
114- Sometimes, the RCON server will send fragmented packets.
115- This is because RCON has a maximum packet size of 4096 bytes.
116- RCONClient will automatically handle packet fragmentation for you.
114+ The RCON Protocol has an outgoing(client to server) packet size limitation of 1460 bytes.
115+ Taking into account the mandatory information we have to send(request ID, type, padding, ect.),
116+ the maximum command size that can be sent is 1446 bytes.
117+
118+ This limitation unfortunately has no workaround,
119+ and is an issue with the RCON protocol, and therefore beyond our control.
120+ mctools does implement a length check to make sure outgoing packets are not too big.
121+
122+ If an outgoing packet is too big, and the length check is enabled,
123+ then an 'RCONLengthError' exception will be raised, and the packet will not be sent.
124+ This ensures that any nasty side effects of going over the outgoing limit will be avoided,
125+ thus keeping the connection in a stable state.
126+
127+ You can optionally disable the outgoing length check by passing 'length_check=False' to the command method.
128+
129+ .. warning ::
130+
131+ Disabling outgoing length checks is not recommended! Doing so could mess up the state of your client!
132+
133+ Here is an example of disabling outgoing length checks:
117134
118- If the packet received is 4096 bytes in length, then we will assume the packet is fragmented.
119- We send a junk packet to the server, and read packets until the server acknowledges the junk packet.
120- RCON ensures that all packets are sent in the order that they are received, meaning that once the server responds to
121- the junk packet, then we can be sure that we have all of the relevant packets.
135+ .. code-block :: python
136+
137+ # Lets send a HUGE command:
138+ # (Assume 'huge_command' is a string containing a command larger than 1446 bytes)
139+
140+ resp = rcon.command(huge_command, length_check = False )
141+
142+ This will prevent the 'RCONLengthError' exception from being raised,
143+ and mctools will send the large packet normally.
144+
145+ If a large packet is sent to the RCON server, then some nasty things could occur.
146+ The most likely is that the server will forcefully close the connection,
147+ although other unsavory events could occur.
148+ This is why we recommend keeping the outgoing length check enabled.
149+
150+ RCON Incoming Packet Fragmentation
151+ __________________________________
152+
153+ Sometimes, the RCON server will send fragmented packets.
154+ This is because RCON has an incoming(server to client) maximum packet size of 4096 bytes.
155+ RCONClient will automatically handle incoming packet fragmentation for you.
156+
157+ If the incoming packet is 4096 bytes in length, then we will assume the packet is fragmented.
158+ If this is the case, then mctools sends a junk packet to the server,
159+ and reads packets until the server acknowledges the junk packet.
160+ The RCON protocol ensures that all packets are sent in the order that they are received,
161+ meaning that once the server responds to the junk packet,
162+ then we can be sure that we have all of the relevant packets.
122163We then concatenate the packets we received, and return it as one.
123164
124165However, you can disable the check by passing 'frag_check=False' to the command method.
@@ -135,7 +176,7 @@ Here is an example of disabling RCON packet fragmentation:
135176
136177 resp = rcon.command(" help" , frag_check = False )
137178
138- This will return the content of the first 4096 bytes. Any subsequent to 'command' or 'raw_send' will return the rest
179+ This will return the content of the first 4096 bytes. Any subsequent call to 'command' or 'raw_send' will return the rest
139180of the fragmented packets. This means that you will have incomplete content, and subsequent calls will return
140181irrelevant information. Unless you have a reason for this, it is recommended to keep packet fragmentation enabled.
141182
0 commit comments