Bukkit read timed out



Are you perhaps familiar with the two phrases:

read timed out
connection reset

Since recently I have become quite familiar with them myself and in this post I will describe how to get rid of them.

Reason 1 - Rouge plugin

Reason Description

Minecraft is mainly single-threaded. The main thread has a formal name when you look in the source code. It is called "Server thread". If a plugin isn't coded correctly the "Server thread" may get stuck in an eternal loop. Here is such an example: unsafe loop in xAuth. What if the player is floating over the void in a skylands-world (all empty but for some floating islands)? The while-loop would never cancel and the "Server thread" would get stuck.

Reason Solution

You may have 50 plugins installed. How do you find the plugin causing the issue? I use CraftBukkit++ (called CB++). It has a nice feature that comes in handy in this situation. If the "Server thread" hangs CB++ will output a thread-dump. That thread-dump is visible both in the console and in server.log. I searched for "Server thread" and found this:

2012-04-26 08:05:47 [SEVERE] ------------------------------
2012-04-26 08:05:47 [SEVERE] Current Thread: Server thread
2012-04-26 08:05:47 [SEVERE]     PID: 13 | Alive: true | State: RUNNABLE
2012-04-26 08:05:47 [SEVERE]     Stack:
2012-04-26 08:05:47 [SEVERE]         org.bukkit.craftbukkit.block.CraftBlock.isEmpty(CraftBlock.java:327)
2012-04-26 08:05:47 [SEVERE]         com.cypherx.xauth.listeners.xAuthPlayerListener.onPlayerMove(xAuthPlayerListener.java:215)
2012-04-26 08:05:47 [SEVERE]         sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)
2012-04-26 08:05:47 [SEVERE]         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2012-04-26 08:05:47 [SEVERE]         java.lang.reflect.Method.invoke(Method.java:601)
2012-04-26 08:05:47 [SEVERE]         org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301)
2012-04-26 08:05:47 [SEVERE]         org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
2012-04-26 08:05:47 [SEVERE]         org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:461)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.NetServerHandler.a(NetServerHandler.java:209)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.Packet10Flying.handle(SourceFile:126)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
2012-04-26 08:05:47 [SEVERE]         org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:169)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:92)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.MinecraftServer.w(MinecraftServer.java:625)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.MinecraftServer.run(MinecraftServer.java:506)
2012-04-26 08:05:47 [SEVERE]         net.minecraft.server.ThreadServerApplication.run(SourceFile:492)

This line tell us the location of the bad code:

com.cypherx.xauth.listeners.xAuthPlayerListener.onPlayerMove(xAuthPlayerListener.java:215)

Reason 2 - todo

I will add more reasons as I find them.