[0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages

Bugs that are actually features.
Nicksaurus
Long Handed Inserter
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

Post by Nicksaurus »

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:
Screenshot.png
Screenshot.png (37.11 KiB) Viewed 2444 times
Attachments
RCON test.7z
(3.52 KiB) Downloaded 92 times
Last edited by Nicksaurus on Thu Jan 23, 2020 9:52 pm, edited 1 time in total.
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages

Post by Impatient »

The files are missing.
Nicksaurus
Long Handed Inserter
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

Post by Nicksaurus »

Impatient wrote: Thu Jan 23, 2020 9:46 pm The files are missing.
Weird. They're back now, thanks for pointing it out
Rseding91
Factorio Staff
Factorio Staff
Posts: 14250
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages

Post by Rseding91 »

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.
If you want to get ahold of me I'm almost always on Discord.
Hornwitser
Fast Inserter
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

Post by Hornwitser »

Rseding91 wrote: Tue Feb 25, 2020 1:29 pm The game sends join/leave messages to connected rcon clients. If you want to ignore them, then just ignore them.
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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14250
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.0] Server sometimes adds 'player joined the game' logs to RCON messages

Post by Rseding91 »

Hornwitser wrote: Tue Feb 25, 2020 4:52 pm
Rseding91 wrote: Tue Feb 25, 2020 1:29 pm The game sends join/leave messages to connected rcon clients. If you want to ignore them, then just ignore them.
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.
When the event happens the game sends the message of "player joined game" to your RCON connection.
If you want to get ahold of me I'm almost always on Discord.
Hornwitser
Fast Inserter
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

Post by Hornwitser »

Rseding91 wrote: Tue Feb 25, 2020 4:59 pm When the event happens the game sends the message of "player joined game" to your RCON connection.
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.
Post Reply

Return to “Not a bug”