I've set up a headless server and a client on my PC for testing communication with mods via RCON messages, and sometimes if I send an RCON request to the server from an external program at the same time as logging in with the client, I get a response that includes the '[player] joined the game' command line output and crashes my program because the header reports an incorrect message size
I've attached a VS2019 project that reproduces the issue fairly reliably by spamming the server with messages until it happens.
To reproduce:
* Run the server with rcon enabled (I use 'factorio --start-server-load-latest --rcon-bind 127.0.0.1:31245 --rcon-password asdf')
* Run the test program
* Run a factorio instance and connect to the server at 127.0.0.1:34197
* The program should receive a response something like this:
[0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
-
- Long Handed Inserter
- Posts: 55
- Joined: Thu Aug 28, 2014 12:56 pm
- Contact:
[0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
- Attachments
-
- RCON test.7z
- (3.52 KiB) Downloaded 93 times
Last edited by Nicksaurus on Thu Jan 23, 2020 9:52 pm, edited 1 time in total.
Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
The files are missing.
-
- Long Handed Inserter
- Posts: 55
- Joined: Thu Aug 28, 2014 12:56 pm
- Contact:
Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
Thanks for the report however when I test your program it works correctly and there's no invalid message size being received.
I did notice you are ignoring the return value of recv and expecting that it always reads the full number of bytes you ask for - which isn't correct. But at no point does it crash with an invalid message size.
The game sends join/leave messages to connected rcon clients. If you want to ignore them, then just ignore them.
I did notice you are ignoring the return value of recv and expecting that it always reads the full number of bytes you ask for - which isn't correct. But at no point does it crash with an invalid message size.
The game sends join/leave messages to connected rcon clients. If you want to ignore them, then just ignore them.
If you want to get ahold of me I'm almost always on Discord.
-
- Fast Inserter
- Posts: 214
- Joined: Fri Oct 05, 2018 4:34 pm
- Contact:
Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
What do you mean with the game sends join/leave messages to connected RCON clients, exactly how is this done, what circumstance causes it to happen, and where is it documented? I tried reproducing this in 0.18.6 with both a Windows and a Linux server and had no luck.
Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
When the event happens the game sends the message of "player joined game" to your RCON connection.Hornwitser wrote: ↑Tue Feb 25, 2020 4:52 pmWhat do you mean with the game sends join/leave messages to connected RCON clients, exactly how is this done, what circumstance causes it to happen, and where is it documented? I tried reproducing this in 0.18.6 with both a Windows and a Linux server and had no luck.
If you want to get ahold of me I'm almost always on Discord.
-
- Fast Inserter
- Posts: 214
- Joined: Fri Oct 05, 2018 4:34 pm
- Contact:
Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages
No, that is absolutely not what happens. Why are you so unspecific and vague? The server doesn't send anything to the RCON connection on its own, after the RCON connection is established the client sends SERVERDATA_EXECCOMMAND packets to run commands whenever it wants and the server respond with exactly one SERVERDATA_RESPONSE_VALUE packet for each of those. But there's no "the game sends the message to your RCON connection", if you establish a connection and wait the server doesn't send anything to you.
Either way, I managed to reproduce this "feature", which was more difficult than expected. It works as follows: For the first RCON connection that is established with the server and only the first one, the server will send the yyyy-mm-dd formatted log messages that has occurred since the last time the messages were sent, prepended to the response to SERVERDATA_EXECCOMMAND packets the client sends with an id of 0. Since most RCON clients either choose a random id or cycle through 2^32 ids before reusing the id of 0 you pretty much never see this behavior happen.
Please do not fix this, it will break pretty much all third party integrations with Factorio (including Clusterio) that uses RCON to pull data out of the game as they do not expect the response to contain random log messages.