Tiiffi/mcrcon

Invalid Packet size (-551878174)

OIITCONZ opened this issue · 23 comments

I'm getting an error when trying gto connect mcrcron in Windows 7 to Linux MC. Latest version.

Warning: invalid packet size (-551878174). Must over 10 and less than 4096.
Authentication failed!

Command line is:
@mcrcon.exe -t -H redacted.com -P 12345 -p redactedpassword

Name: mcrcon (minecraft rcon)
Version: 0.7.1
Date: 02.01.2020

Same

Are your Windows 7 machine and server 32-bit or 64-bit?

Well, I thought this might have something to do with packet size being defined as an int instead of size_t, but the winsock implementation of recv calls for an integer, so that probably isn't the issue. Now I'm wondering if it has to do with the endianness of the data being sent from the server. Are you using the Minecraft server provided by Mojang, or something third party?

Hello,

I have been off from the project for a while now but I can check if I can reproduce this problem.

  • Is this problem happening every time?
  • And what is the exact version of the Minecraft server?

Now I'm wondering if it has to do with the endianness of the data being sent from the server.

I believe endianness may become a problem on some rarer platforms.

Older versions of the mcrcon source even had endiannes related functions but endian-independent code was never implemented because I didn't have good way to test it.

Currently packet handling is is pretty ugly and probably one of the oldest part of the code and I feel it needs refactoring anyway.

So, I need way to reproduce this before I can fix it.

It happen when you defined -p (default port) if you just omitted it, it doesn;t happen.
So i just used the default port and it works

I've same problem
Im in ubuntu 20.10
My serv use forge-1.12.2 (latest 1.12.2 version)
third party hosting

My 1.12.2 server.properties have lines:
enable-rcon=true
rcon.port=25575
rcon.password=my_rcon_pasword
broadcast-rcon-to-ops=true

In my linux terminal I use:
$ mcrcon -H my.serv.ip.or.domain -P 25575 -p my_rcon_pasword

Result:
Warning: invalid packet size (-98893315). Must over 10 and less than 4096.
Authentication failed!

:'c

I've same problem
Im in ubuntu 20.10
My serv use forge-1.12.2 (latest 1.12.2 version)
third party hosting

My 1.12.2 server.properties have lines:
enable-rcon=true
rcon.port=25575
rcon.password=my_rcon_pasword
broadcast-rcon-to-ops=true

In my linux terminal I use:
$ mcrcon -H my.serv.ip.or.domain -P 25575 -p my_rcon_pasword

Result:
Warning: invalid packet size (-98893315). Must over 10 and less than 4096.
Authentication failed!

:'c

It happen when you defined -p (default port) if you just omitted it, it doesn;t happen.
So i just used the default port and it works

Use the mcrcon's default port and it'll work fine
$mcrcon -H my.serv.ip.or.domain -p my_rcon_pasword

Ok, after researching and doing a lot of testing, i have found that this error only happens with certain specific ports.

For example:
This error occurs to me when setting port 25575 in server.properties

And I execute:
$ mcrcon -H my.serv.ip.or.domain -P 25575 -p my_rcon_pasword

It also happens if I omit the port (25575 default):
$ mcrcon -H my.serv.ip.or.domain -p my_rcon_pasword

The server console shows when starting the server that this service is already being used.
I assume it refers to port 25575 of my server.

So I solved the problem by changing to a random port not occupied by any service in server.properties. (I use 2525)

In my server.properties:
rcon.port = 2525

I hope this can help someone

I had the same issue on an Ubuntu Linux server.

Changing the RCON port from 25575 to 55565 (or anywhere inside the private port range of 49152-65535) worked.

Maybe you could add a check and provide a more helpful error message?

Same on ubuntu if rcon in sh file. I added -P with def port and it works

Same problem on Ubuntu 20.04

Logged in. Type 'quit' or 'exit' to quit.
>help
Warning: invalid packet size (4106). Must over 10 and less than 4096.
>/help
Warning: invalid packet size (1852795252). Must over 10 and less than 4096.
>

I probably would have to see tcpdump of the traffic to determine what is actually going on.

It is possible that there is another service running on default Minecraft rcon port (25575) and mcrcon is somehow succesfully connecting but getting nonsensical packets back from the whatever service it connected.

I simply changed DATA_BUFFSIZE from 4096 to 8192. Now commands like help work correctly.

I'll be honest, my issue was rcon was disabled, and I needed to switch to the "listening" IP. I wish I would have found this post sooner, I would have done a TCPdump for you.

Before
image
After
image

@ambercap

I simply changed DATA_BUFFSIZE from 4096 to 8192. Now commands like help work correctly.

In this case server is probably sending multipacket response which is not supported by mcrcon.
Currently I am writing new rcon library which will address this.


@jasonkuehl
Hi, Could you still provide tcpdump when this problem happens?

I am still wondering why the rcon client is getting responses in some cases even though the port or listening ip is set incorrectly.
Maybe firewall or something else is sending stuff into socket and mcrcon tries to handle the data as rcon packet.

Closing issue. This is going nowhere.

I know this issue is close @Tiiffi but I was able to reproduce it on Ubuntu x64 machine. Curious if you saw this in another rcon-related tool -- https://mctools.readthedocs.io/en/master/rcon.html

The RCON Protocol has an outgoing(client to server) packet size limitation of 1460 bytes. Taking into account the mandatory information we have to send(request ID, type, padding, ect.), the maximum command size that can be sent is 1446 bytes.

This limitation unfortunately has no workaround, and is an issue with the RCON protocol [...]


image

Interestingly, the stop command actually stopped the server even though I got the packet error

Hello @saicrazyfire

That 1446 / 1460 byte outgoing packet size limit is certainly a new thing to me. It is not documented in Valvesoftware wiki. Thanks for the info, I have to investigate this further.

This protocol is actually quite poorly documented and differenet games have their own quirky implementations of it. This makes it hard to write compatible clients.


Now for the packet size problem.

  • What exact server and server version you are running?

Correct maximum packet size should be 4106 and I will correct this in next release.
But I am just wondering if your server is just sending one maximum size packet or trying to send multipacket response (all the help response in one go).

Thanks.

You might have to look into Minecraft's RCON protocol instead of Valve's RCON protocol. Seems like they're not interchangeable.

From the same library I linked above:

The Minecraft RCON protocol allows admins to remotely execute Minecraft commands. The Minecraft RCON protocol is an implementation of the Source RCON protocol.

The library also links to a helpful guide on Minecraft's implementation of RCON here

Edit: more info

For your question

But I am just wondering if your server is just sending one maximum size packet or trying to send multipacket response (all the help response in one go).

The library above makes it seems like Minecraft sends packets up to 4096 bytes, but it can also send multiple packets for the request if it is >4096 total bytes. The specific library I linked assumes if RCON server sends out a 4096 byte packet, it is a multi-packet response

Sometimes, the RCON server will send fragmented packets. This is because RCON has an incoming(server to client) maximum packet size of 4096 bytes.

If the incoming packet is 4096 bytes in length, then we will assume the packet is fragmented. If this is the case, then mctools sends a junk packet to the server, and reads packets until the server acknowledges the junk packet. The RCON protocol ensures that all packets are sent in the order that they are received, meaning that once the server responds to the junk packet, then we can be sure that we have all of the relevant packets. We then concatenate the packets we received, and return it as one.


For my hosting server, I'm running Ubuntu 20.04.3 LTS. On top of that, I'm actually running a modded Minecraft server (FTB Oceanblock), but that should be less relevant; Minecraft RCON should still work on it. It's based on Minecraft 1.16.5, iirc

Disappointing that this went nowhere, I'd provide tcpdumps if I could.