Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Kick message: Internal Exception: java.io.IOException: An existing connection was forcibly closed by the remote host

Featured Replies

Posted

I've got a mod which some of my users tell me they get disconnected from multiplayer servers randomly when by this error message:

image.png

The only thing I can think that is doing this is that my mod contacts my web server to update the user's statistics so they can check on the website. It makes a simple GET request via HttpUrlConnection as shown below,ย in a different thread, so it doesn't freeze the game:

public static JsonObject sendGETRequest(String urlString) throws SocketTimeoutException {
        try {
            System.out.println("Sending request to: " + urlString);
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setConnectTimeout(3000);
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
            StringBuilder sb = new StringBuilder();
            int cp;
            while ((cp = reader.read()) != -1) {
                sb.append((char) cp);
            }
            String output = sb.toString();
            JsonObject json = new JsonParser().parse(output).getAsJsonObject();
            connection.getInputStream().close();
            return json;
        } catch (SocketTimeoutException e){
            throw e;
        } catch (IOException e){
            e.printStackTrace();
        }
        return null;
    }

The IO exception shows this in the console:

[22:36:48] [Netty Client IO #0/ERROR]: NetworkDispatcher exception
java.io.IOException: An existing connection was forcibly closed by the remote host
	at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_51]
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_51]
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_51]
	at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[?:1.8.0_51]
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[?:1.8.0_51]
	at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:446) ~[UnpooledUnsafeDirectByteBuf.class:4.0.23.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881) ~[AbstractByteBuf.class:4.0.23.Final]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:225) ~[NioSocketChannel.class:4.0.23.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [AbstractNioByteChannel$NioByteUnsafe.class:4.0.23.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [NioEventLoop.class:4.0.23.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [NioEventLoop.class:4.0.23.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [NioEventLoop.class:4.0.23.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [NioEventLoop.class:4.0.23.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [SingleThreadEventExecutor$2.class:4.0.23.Final]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]

Which isn't very helpful from what I can see.

Any help would be greatly appreciated. Also I'm not saying that the connection is the problem but that's all I can suspect. I've now printed stuff before it makes the connection to find out if it was that but I'd have to push the update to users to find out and I don't want to have them download a new update just to see if it could be this bug.

Edited by Jaffaaaa

Is this error preventing them from rejoining? Is it happening so frequently that they cannot play, or is it simply something you do not want happening at all? This has happened to myself and friends in the past but never keeps us from rejoining and is usually only a once in a while thing. We usually just restarted our game quick and rejoined the server.

ย 

  • Author
29 minutes ago, NinjaSenpai3773 said:

Is this error preventing them from rejoining? Is it happening so frequently that they cannot play, or is it simply something you do not want happening at all? This has happened to myself and friends in the past but never keeps us from rejoining and is usually only a once in a while thing. We usually just restarted our game quick and rejoined the server.

ย 

Nah, happens randomly from 20 minutes to a few hours. It wouldn't be that much of a problem if part of the mod wasn't AFK'ing haha

  • Jaffaaaa changed the title to Kick message: Internal Exception: java.io.IOException: An existing connection was forcibly closed by the remote host

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.