PocketMine-MP
PocketMine-MP copied to clipboard
Apply restrictions on when packets can be sent or received
Issue description
Today I encountered an issue while working on a fix for #452, where my client was randomly disconnecting from the server while logging in. I pinpointed this issue to something sending the wrong packets too early in the login sequence, causing errors on the client side and the occasional crash.
This is also a problem for plugins which send packets, or which use API methods which may cause sending of packets (and there are a very large number of such methods!) and as a result cause unexplained disconnections and/or client-sided crashes.
OS and versions
- PocketMine-MP: bb7968448048430d09ad33ca9a35322d325aa7f9 with local changes for #452
- PHP: 7.0.16 with xdebug and assertions
- Server OS: w10
- Game version: all
Whilst sending these packets shouldn't be done before login, wouldn't it be a good idea to queue them until after login? It'll probably encourage laziness among plugin developers though and is probably something that requires input from multiple, more knowledgeable people.
May not be related to this, but the RakLib thread seems to have a bandwidth problem. Timeouts are becoming a issue, and many people are noticing there players are timing out as well. A quick glance at the upload / download speeds on the console title shows a average of 0.70 upload kb/s & 2.34 kb/s download for me.
On the 1.4 based project, on my same machine, the title tick shows 403.32 kb/s upload speed and a download speed of 708.1 kb/s and there is no timeout problem. Strange.
New network architecture in 4.0 addresses problems with receiving packets at the wrong time, and also sending packets in the wrong direction. The issue of the server sending packets at the wrong time is still unsolved.