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

Illegal Argument Exception thrown #8

Open
MillzyDev opened this issue Jul 27, 2021 · 5 comments
Open

Illegal Argument Exception thrown #8

MillzyDev opened this issue Jul 27, 2021 · 5 comments

Comments

@MillzyDev
Copy link

MillzyDev commented Jul 27, 2021

Hello, I'm attempting to make a discord application using your RCON library, I followed your example closely and ive double checked that all the credentials are correct, however I get the IllegalArgumentException that gets thrown

        final MinecraftRconService minecraftRconService = new MinecraftRconService(
                new RconDetails("play.pintodog.com", 25565, "secret_password"),
                ConnectOptions.defaults()
        );

        minecraftRconService.connectBlocking(Duration.ofSeconds(3));

        final MinecraftRcon minecraftRcon = minecraftRconService.minecraftRcon().orElseThrow(IllegalStateException::new); // fails here

        final CustomCommand customCommand = new CustomCommand(String.join(" ", args));

        Future<RconResponse> response = minecraftRcon.sendAsync(customCommand);

        Logger.info("Executed RCON Command: " + String.join(" ", args));

i'll link my CustomCommand class here: https://pastebin.com/me4KjDYy,
any help would be very much appreciated

@MrGraversen
Copy link
Owner

Hi, thanks for reaching out.

What is the console output when running?
Which version of the library are you using? 0.0.16?

Even if I don't know your RCON password, I can see:

java.lang.IllegalArgumentException: capacity < 0: (-551943712 < 0)
	at java.nio.Buffer.createCapacityException(Buffer.java:256) ~[?:?]
	at java.nio.ByteBuffer.allocate(ByteBuffer.java:347) ~[?:?]
	at io.graversen.minecraft.rcon.MinecraftClient.readData(MinecraftClient.java:133) ~[minecraft-rcon-0.0.16.jar:?]
	at io.graversen.minecraft.rcon.MinecraftClient.readResponse(MinecraftClient.java:110) ~[minecraft-rcon-0.0.16.jar:?]
	at io.graversen.minecraft.rcon.MinecraftClient.lambda$doSynchronousSend$0(MinecraftClient.java:100) ~[minecraft-rcon-0.0.16.jar:?]
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java) ~[?:?]
	... 3 more

It seems to attempt to read a negative amount of bytes, which could indicate that the underlying AsynchronousSocketChannel is in fact closed.

I don't know how you are hosting this Minecraft server, but be wary of going through a reverse proxy, as it is quite challenging to make work without protocol knowledge.

In either case – I'm running this library on 0.0.16 in production with a Spring Boot web application on top of it for many months now, so the library has some battle testing even across several Minecraft updates etc. 😄

@MillzyDev
Copy link
Author

MillzyDev commented Jul 27, 2021

Thanks for the quick reply!

What is the console output when running?

12:15:28.683 [JDA MainWS-ReadThread] ERROR net.dv8tion.jda.api.JDA - One of the EventListeners had an uncaught exception
java.lang.IllegalStateException: null
	at java.util.Optional.orElseThrow(Optional.java:403) ~[?:?]
	at com.pintodog.autoadmin.command.commands.RCON.handle(RCON.java:39) ~[classes/:?]
	at com.pintodog.autoadmin.CommandManager.handle(CommandManager.java:103) ~[classes/:?]
	at com.pintodog.autoadmin.Listener.onGuildMessageReceived(Listener.java:137) ~[classes/:?]
	at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:481) ~[JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:160) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:97) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:952) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:839) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:817) [JDA-4.3.0_291.jar:4.3.0_291]
	at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:990) [JDA-4.3.0_291.jar:4.3.0_291]
	at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) [nv-websocket-client-2.14.jar:?]
	at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) [nv-websocket-client-2.14.jar:?]

Which version of the library are you using? 0.0.16?

I am using the latest version, yes

@MrGraversen
Copy link
Owner

Have you verified the RCON exchange using another client?

@MillzyDev
Copy link
Author

How so?

@MrGraversen
Copy link
Owner

My guess is currently that some network issue prevents you from connecting. However, I am unsure how to assist you with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants