Tiiffi / mcrcon

Rcon client for Minecraft
https://github.com/Tiiffi/mcrcon/
zlib License
834 stars 116 forks source link

Invalid Packet size (-551878174) #45

Open OIITCONZ opened 4 years ago

OIITCONZ commented 4 years ago

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 commented 4 years ago

Same

tmanifold commented 4 years ago

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

OIITCONZ commented 4 years ago

Win 7 - 64 bit


From: "Tyler M" notifications@github.com Sent: Saturday, May 9, 2020 4:40 PM To: "Tiiffi/mcrcon" mcrcon@noreply.github.com Cc: "OIITCONZ" itsupport@outsourcedit.co.nz, "Author" author@noreply.github.com 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.

tmanifold commented 4 years ago

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 commented 4 years ago

Hello,

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

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 commented 4 years ago

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

redBaron23 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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_rconpasword

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

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 commented 4 years ago

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 commented 4 years ago

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

Haggle1996 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

jasonkuehl commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

Closing issue. This is going nowhere.

saicrazyfire commented 2 years ago

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 commented 2 years ago

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.

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.

saicrazyfire commented 2 years ago

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 commented 7 months ago

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

timisaurus commented 3 weeks ago

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