I have had this issue once, and I have seen in streams that people had this issue as well.
I have some tips that might help or fix the issue:
1. Install the newest version of minecraft. (1.12)
2. When you see this error, just try entering the server until it doesn't happen. So, try reconnecting to cubecraft up to 5 times, if after 5 tries it doesn't work then try one of the others.
3. Disconnect to the wifi network, and then reconnect to it again.
4. Restart your router.
5. If none of these work, you should try re-installing minecraft.
6. If nothing works at all, try researching on the internet a bit and see if you find something.
I wish you the best of luck! ;)