Currently I'm working on load-balancing RakNet, and for this reason I tried to use an nginx server with ip-based consistent hashing. But as a result the server had no ping, but I also tried to connect, and the RakNet Handshake started, but didn't complete, as a result, there is now a Server in the Friends LAN Games, the ping is working, but I'm not able to remove it again.
To reproduce it:
Set-up a bedrock server with localhost ip and random port
Set-up a nginx server
Try to connect via the nginx server => now there is an unremovable server (even after restarting the game / the computer)
Linked issues
Comments 4
I finally found out the solution to nginx reverse proxying a bedrock server! Since Bedrock servers run on RakNet, the session across the proxy must be kept. If you look at http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html, you'll see that normally, every request becomes a new session. You don't want this. For the solution to work, you'll need to have NGINX version 1.15.7 and up (http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_requests)! Looking at the documentation for RakNet, in the worst case scenario, packets are sent every 10 milliseconds, eg 100 packets/requests are sent in 1 second (1000 milliseconds in 1 second). This means, that in order to keep the same session between the client and the user for one day, you'll need to hold a session for 8640000 packets/requests (100 packets/sec * 60 sec/min * 60 min/hr * 24 hr/day) (for one week, you'll need to accept 60480000 packets).
If you look at nginx's documentation on "proxy_requests":
Sets the number of client datagrams at which binding between a client and existing UDP stream session is dropped. After receiving the specified number of datagrams, next datagram from the same client starts a new session. The session terminates when all client datagrams are transmitted to a proxied server and the expected number of responses is received, or when it reaches a timeout.
This means that you need to accept 8640000 datagrams for a session that lasts 1 day (the duration of the user staying in the game within a single session before they forcibly disconnect). In other words, the configuration of NGINX should be:
stream {
server {
listen 19132 udp;
proxy_requests 8640000; # 100 * 60 * 60 * 24 -- session lasts for 1 day
proxy_pass <IP_TO_MC_SERVER>:19132;
}
}
With a load balancer:
stream {
upstream balancer {
server <IP_TO_MC_SERVER_1>:19132;
server <IP_TO_MC_SERVER_2>:19132;
server <IP_TO_MC_SERVER_3>:19132;
}
server {
listen 19132 udp;
proxy_requests 8640000; # 100 * 60 * 60 * 24 -- session lasts for 1 day
proxy_pass balancer;
}
}
Obviously, if you want to change the session time, just change proxy_requests. Remember that all communication is over UDP and that you need at least NGINX 1.15.7 for this to work. Cheers!
Cleaning up old tickets: This ticket had been set to 'Awaiting Response', but has not received a response from the reporter (~3 months+) so is being closed as Incomplete. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines which includes steps to reproduce the problem.
For any account or purchasing related issues, please contact Minecraft Customer Support directly, as we cannot assist with those here at the bug tracker.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki
Same! I'm trying to reverse proxy a bedrock server (through nginx):
And I'm getting: "Unable to connect to world.".
I wish there are more logs available on the client side :/