aws-minecraft-proxy icon indicating copy to clipboard operation
aws-minecraft-proxy copied to clipboard

Server refuses the connection immediately

Open tecbeat opened this issue 3 years ago • 11 comments

Hi, I've been using the proxy for about half a year now and I've rebuilt it once. Unfortunately, it is not accessible from the Minecraft launcher although the log shows a login attempt and should actually also start the server, nothing happens. Except that in Minecraft itself a "Failed to connect to the server! Disconnected" and the following log is written:

Dec 30 13:37:27 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal systemd[1]: Stopping Minecraft proxy that automatically starts an EC2 server when a connection is made... Dec 30 13:37:27 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal systemd[1]: Stopped Minecraft proxy that automatically starts an EC2 server when a connection is made. Dec 30 13:37:27 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal systemd[1]: Started Minecraft proxy that automatically starts an EC2 server when a connection is made. Dec 30 13:37:28 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal node[9074]: [info] Listening on :25565 Dec 30 13:37:41 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal node[9074]: Chunk size is 28 but only 11 was read ; partial packet : {"name":"login_start","params":{"username":"Heptap0ds"}}; buffer :00094865707461 Dec 30 13:37:41 ip-xxx-xxx-xxx-xxx.eu-central-1.compute.internal node[9074]: [info] Client connection closed (xxx.xxx.xxx.xxx)

It is not due to the configuration of the securitygroups or the js version because the server is reachable and the js version is the same as the one from before when it worked. Also a ping on the console does not lead to the desired result.

tecbeat avatar Dec 30 '22 13:12 tecbeat

Unfortunately I have long since stopped using the project myself (and shut down my AWS account, so I can't easily boot up a test server). The following is mostly guess-work.

The error Chunk size is 28 but only 11 was read ; partial packet : {"name":"login_start","params":{"username":"Heptap0ds"}} seems to indicate that we have a protocol issue (we only read 11 of the 28 available chunks for the login packet). I'm assuming this would mostly happen if there is a mismatch between the version of node-minecraft-protocol the server is using, and the Minecraft client that is attempting to connect.

What version of minecraft-protocol is installed on the server (npm list minecraft-protocol)? What version of Minecraft are you attempting to connect using?


If you want to, you can try updating minecraft-protocol to the latest version (currently 1.36.2, which supports Minecraft 1.19) and see if that solves the problem.

npm update minecraft-protocol
sudo systemctl restart minecraft-proxy

birjj avatar Dec 30 '22 19:12 birjj

In fact it is the protocol version unfortunately minecraft still can not communicate properly because of an object error. I will now fork the proxy once and locally convert it to the new version. And as soon as it works put a mergerequest here. Is there anything to consider when I take a closer look at the repo here?

tecbeat avatar Dec 31 '22 14:12 tecbeat

I'd assume the problem lies in minecraft-protocol. This project creates an instance of their server, and then start the AWS server when they tell us a client has logged in. Something goes wrong in-between those events.

Either there's an issue with how we use minecraft-protocol (e.g. a mismatch between the installed version and the version of Minecraft client that is trying to connect, as described in my earlier comment) or there's an issue inside minecraft-protocol (in which case an issue should be raised in their repo). It'll take some debugging to figure out which it is.

birjj avatar Jan 01 '23 20:01 birjj

Hi it took me some time to understand the basics. But now I have a clean error message and can go into debugging. If the error message is already familiar to you, it saves me a lot of work.

Error from ::ffff:127.0.0.1 RangeError [ERR_OUT_OF_RANGE]: Deserialization error for login.toServer : Read error for undefined : The value of "offset" is out of range. It must be >= 0 and <= 27. Received -896763878

code: 'ERR_OUT_OF_RANGE', field: 'login.toServer'

And the reference to Object.packet_login_start (eval at compile (node_modules\protodef\src\compiler.js:258:12))

And still many thanks for the help.

tecbeat avatar Jan 02 '23 00:01 tecbeat

That's definitely a protocol issue. Did you get around to upgrading the version of minecraft-protocol? What's the current output of npm list minecraft-protocol, and what version of Minecraft is attempting to connect?

birjj avatar Jan 02 '23 08:01 birjj

I'm using the latest version so [email protected]. On npmjs.com 1.18 and 1.19 are listed, I tried it with those two.

tecbeat avatar Jan 02 '23 17:01 tecbeat

In that case the problem likely should be reported to node-minecraft-protocol.

Just to be sure, could you test out a minimal example and see if you can login with a basic minecraft-protocol server? Running the below on your local machine should create a simple server, which you can then try to connect to on localhost:25565.

# setup the npm folder
mkdir aws-minecraft-proxy-19
cd aws-minecraft-proxy-19
npm init --yes
npm install --save minecraft-protocol
# create our index.js
cat <<EOF > index.js
const mc = require("minecraft-protocol");
const server = mc.createServer({
  "online-mode": true,
  port: 25565,
  keepAlive: false,
  beforePing: data => {
    data.players.max = 0;
    data.version.protocol = 1; // set a known-bad protocol so the user gets an error showing the version name
    data.description.text = "Test server for aws-minecraft-proxy#19";
    data.version.name = "Inactive";
    return data;
  }
});
server.on("login", client => {
  console.log("Player", client.username, "(", client.uuid, ") connected");
  client.end("Successfully connected");
});
server.on("listening", () => {
  console.log("Listening on: 25565");
});
EOF
# run (try to connect to the server on localhost:25565)
node index.js

birjj avatar Jan 02 '23 22:01 birjj

I have executed your code exactly as suggested and additionally as shown in the screenshot. Unfortunately, with both the same error. In addition, I have tried different versions but still had no success. Now I will look at other mc proxies like the problem solved and maybe I can adapt it. Also I managed to set up the proxy local, so now it's easier to just run the index.js and quickly access the proxy in Minecraft itself via localhost.

Screenshot 2023-01-03 120139

tecbeat avatar Jan 03 '23 11:01 tecbeat

If the same error happens with the simple test code, then it is almost certainly an issue with minecraft-protocol, and not related to this project. You might be able to get more help by opening an issue in their repo.

birjj avatar Jan 03 '23 11:01 birjj

Thank you very much then I will open an issue and link here then.

[Edit]: 1.19.1 -1.19.3 do not work yet according to this issue or have not been merged.

tecbeat avatar Jan 03 '23 11:01 tecbeat

Huh, that would explain it. They could certainly clarify their list of supported versions (which currently includes "1.19").

Unfortunately there isn't much for this project to do until they support the newest version of Minecraft. I'll close this issue for now. Thanks for bringing it to my attention though!

birjj avatar Jan 03 '23 11:01 birjj