timvisee / lazymc

💤 Put your Minecraft server to rest when idle.
GNU General Public License v3.0
603 stars 18 forks source link

RCON error on shutdown, empty command #3

Open VindicoRory opened 3 years ago

VindicoRory commented 3 years ago

Works great on startup, but on shutdown it produces 2 errors. [19:39:57 WARN]: Unexpected exception while parsing console command "" and java.lang.IllegalStateException: Asynchronous command dispatch! at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:15) ~[patched_1.16.5.jar:git-Paper-790] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:801) ~[patched_1.16.5.jar:git-Paper-790] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:788) ~[patched_1.16.5.jar:git-Paper-790] at net.minecraft.server.v1_16_R3.DedicatedServer.lambda$executeRemoteCommand$3(DedicatedServer.java:733) ~[patched_1.16.5.jar:git-Paper-790] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.lambda$executeFuture$0(IAsyncTaskHandler.java:48) ~[patched_1.16.5.jar:git-Paper-790] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) ~[?:?] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.execute(IAsyncTaskHandler.java:89) ~[patched_1.16.5.jar:git-Paper-790] at java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1778) ~[?:?] at java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:2001) ~[?:?] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeFuture(IAsyncTaskHandler.java:47) ~[patched_1.16.5.jar:git-Paper-790] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeSync(IAsyncTaskHandler.java:64) ~[patched_1.16.5.jar:git-Paper-790] at net.minecraft.server.v1_16_R3.DedicatedServer.executeRemoteCommand(DedicatedServer.java:712) ~[patched_1.16.5.jar:git-Paper-790] at net.minecraft.server.v1_16_R3.RemoteControlSession.run(SourceFile:81) ~[patched_1.16.5.jar:git-Paper-790]

Im not sure if this is a paper only issue, im just worried about crashing the server not saving chunks or player data correctly.

This happens every shutdown. Version: Paper 1.16.5 Plugins: None Platform: Windows 10

NotJustPizza commented 3 years ago

Did you try to stop your server manually using stop command to see if it will throw same error?

VindicoRory commented 3 years ago

Did you try to stop your server manually using stop command to see if it will throw same error?

No error when stopping the server manually, both in game and via console

NotJustPizza commented 3 years ago

Do you have RCON enabled?

VindicoRory commented 3 years ago

Yep, RCON is enabled

NotJustPizza commented 3 years ago

Did you try to manually send stop command via RCON? Lazymc should shutdown server using RCON only, if it's enabled and configured properly.

References: https://github.com/timvisee/lazymc/blob/master/src/server.rs#L211-L221 https://github.com/timvisee/lazymc/blob/master/src/server.rs#L405-L407

NotJustPizza commented 3 years ago

You can use https://pypi.org/project/mcrcon/ to test RCON.

timvisee commented 3 years ago

That's weird! Judging by

[19:39:57 WARN]: Unexpected exception while parsing console command ""

it looks like it doesn't receive any RCON command. It should receive stop. I didn't come across this during development.

Sadly I haven't found an alternative method to gracefully stop a server (programmatically) on Windows yet. For example, on non-Windows platforms it falls back to an alternative stopping method if RCON fails.

I'll give it a spin as well with that Spigot version to see if I get the same issue.

im just worried about crashing the server not saving chunks or player data correctly.

Yes, errors like this will eventually corrupt your server data.


Do you have RCON enabled?

lazymc should automatically enable and configure it on start (while advanced.rewrite_server_properties is true).

timvisee commented 3 years ago
[19:39:57 WARN]: Unexpected exception while parsing console command ""

Just having tested this, I cannot reproduce this.

I used this JAR on an empty server.


java.lang.IllegalStateException: Asynchronous command dispatch!
    at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:15) ~[patched_1.16.5.jar:git-Paper-790]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:801) ~[patched_1.16.5.jar:git-Paper-790]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:788) ~[patched_1.16.5.jar:git-Paper-790]
    at net.minecraft.server.v1_16_R3.DedicatedServer.lambda$executeRemoteCommand$3(DedicatedServer.java:733) ~[patched_1.16.5.jar:git-Paper-790]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.lambda$executeFuture$0(IAsyncTaskHandler.java:48) ~[patched_1.16.5.jar:git-Paper-790]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) ~[?:?]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.execute(IAsyncTaskHandler.java:89) ~[patched_1.16.5.jar:git-Paper-790]
    at java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1778) ~[?:?]
    at java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:2001) ~[?:?]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeFuture(IAsyncTaskHandler.java:47) ~[patched_1.16.5.jar:git-Paper-790]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeSync(IAsyncTaskHandler.java:64) ~[patched_1.16.5.jar:git-Paper-790]
    at net.minecraft.server.v1_16_R3.DedicatedServer.executeRemoteCommand(DedicatedServer.java:712) ~[patched_1.16.5.jar:git-Paper-790]
    at net.minecraft.server.v1_16_R3.RemoteControlSession.run(SourceFile:81) ~[patched_1.16.5.jar:git-Paper-790]

This looks like a thread-safety bug in Paper or even Minecraft itself. It may be wise to open a bug report there.

pR0Ps commented 2 months ago

Another datapoint - I'm seeing the same thing while running paper-1.21.1-57 on Debian trixie using lazymc v0.2.11

Logs:

 INFO  lazymc::monitor > Server has been idle, sleeping...
[00:33:21 INFO]: Thread RCON Client /127.0.0.1 started
[00:33:21 INFO]: [Rcon: Stopping the server]
[00:33:21 WARN]: Unexpected exception while parsing console command ""
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:1014) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:1004) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:985) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.dedicated.DedicatedServer.lambda$runCommand$4(DedicatedServer.java:817) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:60) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1537) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:201) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1514) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1507) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:135) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1466) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1473) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1318) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:330) ~[paper-1.21.1.jar:1.21.1-57-b483da4]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
[00:33:21 INFO]: Stopping server
[00:33:21 INFO]: Thread RCON Client /127.0.0.1 shutting down
 INFO  lazymc::monitor > Server is now sleeping

I've enabled the RCON option and left the configuration at the default so it rewrites the server.properties when it starts with a known RCON port and random password.

Full configuration file: ```toml # lazymc configuration # # You must configure your server directory and start command, see: # - server.directory # - server.command # # All defaults are commented out, change it if you desire. # You can probably leave the rest as-is. # # You may generate a new configuration with: lazymc config generate # Or find the latest at: https://git.io/J1Fvq [public] # Public address. IP and port users connect to. # Shows sleeping status, starts server on connect, and proxies to server. #address = "0.0.0.0:25565" # Server version & protocol hint. # Sent to clients until actual server version is known. # See: https://git.io/J1Fvx version = "1.21.1|paper|lazymc" protocol = 767 [server] # Server address. Internal IP and port of server started by lazymc to proxy to. # Port must be different from public port. #address = "127.0.0.1:25566" # Server directory, defaults to current directory. directory = "../server/" # Command to start the server. # Warning: if using a bash script read: https://git.io/JMIKH command = "java -Xmx4G -Xms1G -jar paper-1.21.1-57.jar nogui" # Freeze the server process instead of restarting it when no players online, making it resume faster. # Only works on Unix (Linux or MacOS), ignored on Windows freeze_process = false # Immediately wake server when starting lazymc. #wake_on_start = false # Immediately wake server after crash. #wake_on_crash = false # Probe required server details when starting lazymc, wakes server on start. # Improves client compatibility. Automatically enabled if required by other config properties. #probe_on_start = false # Set to true if this server runs Forge. #forge = false # Server start/stop timeout in seconds. Force kill server process if it takes too long. start_timeout = 300 stop_timeout = 300 # To wake server, user must be in server whitelist if enabled on server. #wake_whitelist = true # Block banned IPs as listed in banned-ips.json in server directory. #block_banned_ips = true # Drop connections from banned IPs. # Banned IPs won't be able to ping or request server status. # On connect, clients show a 'Disconnected' message rather than the ban reason. #drop_banned_ips = false # Add HAProxy v2 header to proxied connections. # See: https://git.io/J1bYb send_proxy_v2 = true [time] # Sleep after number of seconds. sleep_after = 120 # Minimum time in seconds to stay online when server is started. minimum_online_time = 300 [motd] # MOTD, shown in server browser. sleeping = "§9⏸ Server is currently paused ⏸\n§7(will start when joined)" starting = "§2⌛ Server is starting... ⌛\n§7(refresh for updates)" stopping = "§4☠ Server is shutting down... ☠\n§7(refresh for updates)" # Use MOTD from Minecraft server once known. #from_server = false [join] # Methods to use to occupy a client on join while the server is starting. # Read about all methods and configure them below. # Methods are used in order, if none is set, the client disconnects without a message. #methods = [ # "hold", # "kick", #] [join.kick] # Kick occupation method. # Instantly kicks a client with a message. # Message shown when client is kicked while server is starting/stopping. starting = "⌛ Server is starting ⌛\n\nPlease reconnect once this completes" stopping = "⌛ Server is currently shutting down ⌛\n\nPlease reconnect once this completes to start it again" [join.hold] # Hold occupation method. # Holds back a joining client while the server is started until it is ready. # 'Connecting the server...' is shown on the client while it's held back. # If the server starts fast enough, the client won't notice it was sleeping at all. # This works for a limited time of 30 seconds, after which the Minecraft client times out. # Hold client for number of seconds on connect while server starts. # Keep below Minecraft timeout of 30 seconds. #timeout = 25 [join.forward] # Forward occupation method. # Instantly forwards (proxies) the client to a different address. # You may need to configure target server for it, such as allowing proxies. # Consumes client, not allowing other join methods afterwards. # IP and port to forward to. # The target server will receive original client handshake and login request as received by lazymc. #address = "127.0.0.1:25565" # Add HAProxy v2 header to forwarded connections. # See: https://git.io/J1bYb #send_proxy_v2 = false [join.lobby] # Lobby occupation method. # The client joins a fake lobby server with an empty world, floating in space. # A message is overlayed on screen to notify the server is starting. # The client will be teleported to the real server once it is ready. # This may keep the client occupied forever if no timeout is set. # Consumes client, not allowing other join methods afterwards. # See: https://git.io/JMIi4 # !!! WARNING !!! # This is highly experimental, incomplete and unstable. # This may break the game and crash clients. # Don't enable this unless you know what you're doing. # # - Server must be in offline mode # - Server must use Minecraft version 1.16.3 to 1.17.1 (tested with 1.17.1) # - Server must use vanilla Minecraft # - May work with Forge, enable in config, depends on used mods, test before use # - Does not work with other mods, such as FTB # Maximum time in seconds in the lobby while the server starts. #timeout = 600 # Message banner in lobby shown to client. #message = "§2Server is starting\n§7⌛ Please wait..." # Sound effect to play when server is ready. #ready_sound = "block.note_block.chime" [lockout] # Enable to prevent everybody from connecting through lazymc. Instantly kicks player. #enabled = false # Kick players with following message. message = "§7⛏§9 Server is undergoing maintenance §7⛏§r\n\nPlease come back later" [rcon] # Enable sleeping server through RCON. # Must be enabled on Windows. enabled = true # Server RCON port. Must differ from public and server port. #port = 25575 # Server RCON password. # Or whether to randomize password each start (recommended). #password = "" #randomize_password = true # Add HAProxy v2 header to RCON connections. # See: https://git.io/J1bYb #send_proxy_v2 = false [advanced] # Automatically update values in Minecraft server.properties file as required. #rewrite_server_properties = true [config] # lazymc version this configuration is for. # Don't change unless you know what you're doing. version = "0.2.11" ```