The stack trace lead me to find out that the client sending a plain text message crashed the thread. Adding a try-catch statement fixes this problem. As the commenter said, I should never use catch (Exception ignored) {} in my script, unless absolutely needed.