Lost connection to server

Posts 1–6 of 6 · Page 1 of 1
Lost connection to server
A program I'm making connects to RotMG and should just sit in the nexus, however I'm getting a FAILURE packet with the message "Lost connection to server" after the 11th NEWTICK packet every time. I'm sending an UPDATEACK for every UPDATE packet and a PONG for every PING.

I'm calculating time with (now - start); where start is initialized at the beginning of the program and represents unix epoch milliseconds.

I'm not sending any LocationRecords in the MOVE(which I send with the correct tick ID from the previous NEWTICK) packet because I'm not moving so afaik they're not needed.
As far as I can tell the position coords I'm sending are correct as I get them from the first NEWTICK packet and without moving they don't/shouldn't change.

Am I doing something wrong? Am I missing something?
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.
I'm fairly certain the problem is that you are not sending the correct value for the "serial" field in your PONG packet. I did some quick tests with a clientless program of my own, and was able to consistently cause the bot to disconnect after 10 new tick packets by sending the wrong serial value.

Interestingly, the PONG packet also has a "time" field, but the value of this doesn't seem to be validated. Sending 0 (or any other value) for the time will not cause the bot to disconnect.
Quote Originally Posted by Killer Be Killed View Post
I'm fairly certain the problem is that you are not sending the correct value for the "serial" field in your PONG packet. I did some quick tests with a clientless program of my own, and was able to consistently cause the bot to disconnect after 10 new tick packets by sending the wrong serial value.

Interestingly, the PONG packet also has a "time" field, but the value of this doesn't seem to be validated. Sending 0 (or any other value) for the time will not cause the bot to disconnect.
I tripple checked, I'm sending the exact same serial I receive in the PING packet.
Quote Originally Posted by crally View Post
I tripple checked, I'm sending the exact same serial I receive in the PING packet.
Is there a chance you have specified the data type of the serial field incorrectly?

I have done a little bit more testing and was able to conclude that out of the 3 necessary ack packets you have to send,
  • Update ack has no fields, so it can never be incorrect.
  • Move only has 2 important fields, the tickId and the position. If either of those are incorrect you will be disconnected instantly. (incorrect values for other fields surprisingly will not disconnect you).
  • Pong has one important field, serial, which causes a disconnect after 10 new ticks if it is wrong.


For an incorrect data type to actually be a problem, the type which the field is read as has to be different to the type which it is written as. Which would mean that the data type of the serial field in the Ping packet doesn't match that of the Pong packet.
I think it's unlikely that this is the error, I just can't think of many other possibilities, so it could be good to double check.
I've rechecked all the data types, they're all correct. I should also mention the first PING/PONG only occurs after the 4th NEWTICK, and the DC happens directly after the 11th NEWTICK.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us