mcrcon icon indicating copy to clipboard operation
mcrcon copied to clipboard

Invalid Packet size (-551878174)

Open OIITCONZ opened this issue 4 years ago • 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

OIITCONZ avatar Apr 05 '20 08:04 OIITCONZ

Same

redBaron23 avatar May 03 '20 00:05 redBaron23

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

tmanifold avatar May 09 '20 04:05 tmanifold

Win 7 - 64 bit


From: "Tyler M" [email protected] Sent: Saturday, May 9, 2020 4:40 PM To: "Tiiffi/mcrcon" [email protected] Cc: "OIITCONZ" [email protected], "Author" [email protected] Subject: Re: [Tiiffi/mcrcon] Invalid Packet size (-551878174) (#45)

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

You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

----All Outsourced Information Technology Limiteds work, sales and correspondence is covered under our terms of service and privacy policies found at https://outsourcedit.co.nz/tandc . Our online invoicing system is found at https://invoice.outsourcedit.co.nz and invoices, receipts and quotes can be accessed there. All goods and services sold are covered under the Sale of Goods Act and the Consumer Guarantees Act of NZ and will be liable for GST where applicable.

OIITCONZ avatar May 09 '20 07:05 OIITCONZ

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?

tmanifold avatar May 09 '20 14:05 tmanifold

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.

Tiiffi avatar May 09 '20 16:05 Tiiffi

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

Tiiffi avatar May 16 '20 08:05 Tiiffi

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

redBaron23 avatar May 16 '20 17:05 redBaron23

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

ghost avatar Jun 06 '20 21:06 ghost

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

redBaron23 avatar Jun 07 '20 00:06 redBaron23

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

ghost avatar Jun 17 '20 00:06 ghost

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?

MatthewUtzig avatar Jul 10 '20 15:07 MatthewUtzig

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

MaksymSemenykhin avatar Aug 21 '20 16:08 MaksymSemenykhin

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.
>

Haggle1996 avatar Jan 09 '21 23:01 Haggle1996

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.

Tiiffi avatar Feb 08 '21 03:02 Tiiffi

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

ambercap avatar Sep 08 '21 14:09 ambercap

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

jasonkuehl avatar Dec 06 '21 18:12 jasonkuehl

@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.

Tiiffi avatar Dec 08 '21 14:12 Tiiffi

Closing issue. This is going nowhere.

Tiiffi avatar Dec 18 '21 20:12 Tiiffi

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

saicrazyfire avatar Dec 24 '21 22:12 saicrazyfire

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.

Tiiffi avatar Dec 25 '21 18:12 Tiiffi

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

saicrazyfire avatar Dec 31 '21 00:12 saicrazyfire

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

sesu-tech avatar Jan 16 '24 23:01 sesu-tech