Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Packet size (-551878174) #45

Open
OIITCONZ opened this issue Apr 5, 2020 · 23 comments
Open

Invalid Packet size (-551878174) #45

OIITCONZ opened this issue Apr 5, 2020 · 23 comments
Labels
help wanted Needs help and/or input from community unconfirmed Unconfirmed issues

Comments

@OIITCONZ
Copy link

OIITCONZ commented Apr 5, 2020

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

@redBaron23
Copy link

Same

@tmanifold
Copy link

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

@OIITCONZ
Copy link
Author

OIITCONZ commented May 9, 2020 via email

@tmanifold
Copy link

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?

@Tiiffi
Copy link
Owner

Tiiffi commented May 9, 2020

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
Copy link
Owner

Tiiffi commented May 16, 2020

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

@Tiiffi Tiiffi added the unconfirmed Unconfirmed issues label May 16, 2020
@redBaron23
Copy link

redBaron23 commented May 16, 2020

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

@ghost
Copy link

ghost commented Jun 6, 2020

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

@redBaron23
Copy link

redBaron23 commented Jun 7, 2020

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

@ghost
Copy link

ghost commented Jun 17, 2020

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

@MatthewUtzig
Copy link

MatthewUtzig commented Jul 10, 2020

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?

@MaksymSemenykhin
Copy link

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

@Haggle1996
Copy link

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

@Tiiffi Tiiffi added the help wanted Needs help and/or input from community label Feb 8, 2021
@Tiiffi
Copy link
Owner

Tiiffi commented Feb 8, 2021

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.

@ambercap
Copy link

ambercap commented Sep 8, 2021

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

@jasonkuehl
Copy link

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

@Tiiffi
Copy link
Owner

Tiiffi commented Dec 8, 2021

@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 Tiiffi closed this as completed Dec 18, 2021
@Tiiffi
Copy link
Owner

Tiiffi commented Dec 18, 2021

Closing issue. This is going nowhere.

@saicrazyfire
Copy link

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

@Tiiffi
Copy link
Owner

Tiiffi commented Dec 25, 2021

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 Tiiffi reopened this Dec 25, 2021
@saicrazyfire
Copy link

saicrazyfire commented Dec 31, 2021

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

@sesu-tech
Copy link

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

@timisaurus
Copy link

timisaurus commented Aug 11, 2024

@OIITCONZ Got a working Fork. You can now set the buffer size with an option:
-b buffer size

@Tiiffi I don't see how this is an issue with the port. The error occurs for me if i want to read the content of for example an ender chest or inventory. If the inventory contains to much items and data, which happens fast if there are shulker boxes, its simply the max byte size that is exceeded.

Update: Made it work. Your issue might still be something to do with the port but i managed to increase the response site anyway. Had to add a global buffsize variable for the return packets. MCRCON only ever read the first packet, now it reads every packet until the buffer is full or there are no more packets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Needs help and/or input from community unconfirmed Unconfirmed issues
Projects
None yet
Development

No branches or pull requests