Jump to content

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


Jaffaaaa

Recommended Posts

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
Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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