I'm not sure what's wrong, but RotMG seems to kick the player after 10 instances of incorrect behavior, so if you are getting kicked after the 11th new tick every time, something is likely wrong from the beginning. Your best bet if someone more knowledgeable doesn't answer, or if you have future problems in general, is to read over KillerBeKilled/T.Crane's NRelay code. From the code of his I've looked at, it is incredibly clean and well commented so it should be easy to follow and understand. You can find his github with a google search, and I think he hosts a website with the code and documentation too.