Mincraft Proxy Error
Hi, I have tried to set up the proxy, but unfortunately it cannot be brought to life. The AWS CLI command works but the service is immediately set to failed. All the info I have is in the code box below.
● minecraft-proxy.service - Minecraft proxy that automatically starts an EC2 server when a connection is made
Loaded: loaded (/etc/systemd/system/minecraft-proxy.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Mon 2022-05-09 14:30:57 UTC; 3s ago
Process: 796 ExecStart=/usr/bin/node /home/ec2-user/aws-minecraft-proxy/src/index.js (code=exited, status=1/FAILURE)
Main PID: 796 (code=exited, status=1/FAILURE)
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service: main process exited, code=exited, status=1/FAILURE
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Unit minecraft-proxy.service entered failed state.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service failed.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service holdoff time over, scheduling restart.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Stopped Minecraft proxy that automatically starts an EC2 server when a connection is made.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: start request repeated too quickly for minecraft-proxy.service
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Failed to start Minecraft proxy that automatically starts an EC2 server when a connection is made.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Unit minecraft-proxy.service entered failed state.
May 09 14:30:57 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service failed.```
Could you try running journalctl -u minecraft-proxy.service to see the error log?
Now I have tried to get this module to work (import fs). It works outside, but unfortunately not inside the proxy. Could it be that I have too new a node version? Which one was used to write the proxy? Here are the logs again, thanks for the help.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service holdoff time over, scheduling restart.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Stopped Minecraft proxy that automatically starts an EC2 server when a connection is ma
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Started Minecraft proxy that automatically starts an EC2 server when a connection is ma
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: /home/ec2-user/aws-minecraft-proxy/src/index.js:2
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: import fs from "fs";
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: ^^
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: SyntaxError: Unexpected identifier
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at Module._compile (internal/modules/cjs/loader.js:723:23)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at Module.load (internal/modules/cjs/loader.js:653:32)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at startup (internal/bootstrap/node.js:283:19)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal node[4207]: at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service: main process exited, code=exited, status=1/FAILURE
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Unit minecraft-proxy.service entered failed state.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service failed.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service holdoff time over, scheduling restart.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Stopped Minecraft proxy that automatically starts an EC2 server when a connection is ma
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: start request repeated too quickly for minecraft-proxy.service
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Failed to start Minecraft proxy that automatically starts an EC2 server when a connecti
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: Unit minecraft-proxy.service entered failed state.
May 09 21:46:30 ip-172-31-33-176.eu-central-1.compute.internal systemd[1]: minecraft-proxy.service failed.
It looks like the version of Node you're using might be old enough that it doesn't support ES6 modules. Are you using a Node 13+? What's the output of node -v?
If you are using a recent version of Node, it's most likely unable to locate the package.json file to see that it should load the files as ES6 modules. Are you sure the WorkingDirectory is set correctly in your .service file (cat /etc/systemd/system/minecraft-proxy.service), and that your package.json contains type: "modules"?
Thanks, I used a compatible version and now it works (except for the issue already there).
That's good to hear. As I mentioned in the other issue (#6) I no longer use AWS, so I haven't gotten around to debugging it. If you could help debug the issue (e.g. try out the suggested change) then that'd be super helpful!