rcon icon indicating copy to clipboard operation
rcon copied to clipboard

Unable to return complete information

Open Xingheee opened this issue 1 year ago • 4 comments

It can't return full information

from rcon.source import Client
cmd = "ListPlayers"
with Client('ip', port, passwd='passwd') as client:
        response = client.run(cmd)
        print(response)

Only when I use asynchronous environment, it also can't return full infomation and will return "Unexpected terminator: b'Na'" at the beginning of the message image

Xingheee avatar Mar 11 '24 12:03 Xingheee

I found this in https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses

Multiple-packet Responses
Most responses are small enough to fit within the maximum possible packet size of 4096 bytes. However, a few commands such as cvarlist and, occasionally, status produce responses too long to be sent in one response packet. When this happens, the server will split the response into multiple SERVERDATA_RESPONSE_VALUE packets. Unfortunately, it can be difficult to accurately determine from the first packet alone whether the response has been split.

One common workaround is for the client to send an empty SERVERDATA_RESPONSE_VALUE packet after every SERVERDATA_EXECCOMMAND request. Rather than throwing out the erroneous request, SRCDS mirrors it back to the client, followed by another RESPONSE_VALUE packet containing 0x0000 0001 0000 0000 in the packet body field. Because SRCDS always responds to requests in the order it receives them, receiving a response packet with an empty packet body guarantees that all of the meaningful response packets have already been received. Then, the response bodies can simply be concatenated to build the full response.

Xingheee avatar Mar 11 '24 13:03 Xingheee

Hi. Thanks for the report. Unfortunately I did not yet find the time to look into this. I may implement this over the upcoming Easter weekend.

conqp avatar Mar 25 '24 19:03 conqp

Sorry again. Over the past weekend I was not able to work on this, since I had to do some work because of that xz kerfuffle. Since I am very busy over the next two weeks I will not be able to do any work on this library during this time. If you want to implement this by yourself, I'd be happy to merge an appropriate pull request.

conqp avatar Apr 03 '24 12:04 conqp

I just had briefly time to look into this. I'm currently using a response size-based approach to detect packet fragmentation. Please try lowering the frag_threshold parameter when crating your Client (it currently defaults to 4096).

conqp avatar Apr 04 '24 09:04 conqp