TheRemote / MinecraftBedrockServer

Sets up a Minecraft Bedrock dedicated server on Ubuntu with options for automatic updates and running at startup
https://jamesachambers.com/minecraft-bedrock-edition-ubuntu-dedicated-server-guide/
MIT License
811 stars 173 forks source link

multiple server port issues #106

Closed marcb1387 closed 3 years ago

marcb1387 commented 3 years ago

When running multiple servers I needed to stagger the cron auto reboot since my second server was taking the port of my first server causing the first to crash on start up.

da99Beast commented 3 years ago

Under your minecraft user account you should be able to view/modify your crontab by using the "crontab -e" command.

Here is a link to explain the format for the schedule.

https://help.ubuntu.com/community/CronHowto

TheRemote commented 3 years ago

Your servers are on the same ports? How? That doesn't make sense, and why would you want them to be?

The port is like putting someone's name on an envelope. If you don't put a name on the envelope it would just be delivered to the address but not addressed to a person. Having two servers on the same port would be like having two people living in the same house with the same name. Which one is it supposed to go to? If you have the same ports used there's no way of knowing.

This is a misconfiguration. Your servers should have different IPV4 and different IPV6 ports for each server. They should never overlap like this. I can't imagine what kind of problems you're going to face if you continue with a configuration like this. Having to stagger your startups to even keep them from crashing is going to be the least of your problems over the long term.

This wouldn't even be possible in Java which uses TCP (a connection protocol) instead of Bedrock which uses UDP (connectionless protocol). It would fail to start up no matter how much you staggered it. It's still not going to work right though even though your getting around the port binding because of what I said in the second paragraph. There's no way to know where it's supposed to go. These aren't meant to be shared. This is not supported by Microsoft / Minecraft / etc. and it would have to be to be able to do anything this fancy. They barely support the dedicated server to begin with and haven't fixed all the mentioned multiple server issues in the README for years!

It's actually a failing by Microsoft that it's even possible for you to get around these crashes / protections. What are the crashes saying? Are they saying the port is already in use? It should always say that. It's a bug / mistake that it's not after some period of time, that is for your own protection and it shouldn't let you configure it this way. The port IS in use already by another server and it should always say that no matter how long you wait to start it. It's absolutely supposed to crash because that is an impossible situation that is going to lead to problems.

If I'm misunderstanding let me know (this is my best guess as to what you're talking about) but this should not be a thing unless something is set up improperly here. I figure there's a slight chance you're referring to the ping issue where the server won't show up on the server list unless you start the server in a specific order but you were so nonspecific about it that I honestly doubt it and won't go into that or this will end up being a giant post and I've covered it a bunch of times before (including in the README). Under no circumstances would that ever cause it to crash either so this doesn't sound like that and sounds like exactly what you said / my interpretation here where you really are running servers on duplicate ports.

Probably will not be making any changes for this one. Nothing good can come from having a configuration like this. There's literally no upside to having overlapping ports. The only applications that work like this are ones specifically designed for it (like a web server running several different sites on port 80 with different virtual hosts) but the applications have to be very much designed for it (and configured for it) and Minecraft is not. If I do makes changes related to this it will be to make it check to make sure you aren't trying to do this and not allow you to have duplicate ports!

marcb1387 commented 3 years ago

My servers do have different ports ipv4 and ipv6. the issue is when they both try and start at the same time.

in the logs they show 2 sets of ports

[2021-09-25 04:00:42] [INFO] IPv4 supported, port: 19132 - ports set in server.properties [2021-09-25 04:00:42] [INFO] IPv6 supported, port: 19133 - ports set in server.properties [2021-09-25 04:00:42] [INFO] Server started. [2021-09-25 04:00:42] [INFO] IPv4 supported, port: 33104 [2021-09-25 04:00:42] [INFO] IPv6 supported, port: 42095

this second set is where I have trouble. when both servers reboot at the same time it will for some unknow reason to me start with my first servers ports unless I stagger the reboot times. now if the script would stagger them already it would eliminate issues occurring in the future for others.

in the end im just trying to help prevent issues in the future if this is too much thats fine i was able to work around the problem by stagger my cron reboots of each server by 5 min.

TheRemote commented 3 years ago

Hey marc,

Thanks for clarifying, that is really not what I got from your first post but I did suspect this might have been what you were talking about as legitimately nobody has ever tried to do that that I've heard of. It seemed far more likely you were trying to bring up the thing that has come up here over and over again for years even though it's thoroughly answered/discussed..

Don't be too offended by my original reply as I wrote that with the intention of leaving this information for others who were trying to actually run the server on the same ports. I hadn't really documented that anywhere so I took the chance to write it down if anyone is searching issues for them to find.

I think I can help with this additional information. The issue can usually be eliminated by not using the default ports on any of your servers (19132, 19133). That is the ones that are overlapping. It's a bug. It's been in for years and at this point I'm certain it will never be fixed (it has been like 2-3 years and dozens of major versions). I think they will continue to move in the paid "Realms" cloud server direction and continue to give the dedicated servers the shaft.

You only have to start the servers in a certain order if you are using the default ports on one of them. Here's some references:

https://github.com/TheRemote/MinecraftBedrockServer/issues/19 https://github.com/TheRemote/MinecraftBedrockServer/issues/70 https://github.com/TheRemote/MinecraftBedrockServer/issues/79 https://github.com/TheRemote/MinecraftBedrockServer/issues/101 https://github.com/TheRemote/MinecraftBedrockServer/issues/103

Definitely standard running fare for Bedrock server and has been coming up over and over again for years. It's a bug in the Bedrock server itself and is well known basically. It's also a good 20% of the closed issues for this project and has been coming up since issue #19 (because it used to not actually be a bug years and years ago) and comes up about once every couple of months or so so the answers (and different approaches) are all in those. If I could fix these BDS bugs for them I definitely would!

Staggering them is also fine and is what we used to do before we learned some time ago that if you just don't use the default ports at all on any server you don't have to fight with this.

I'm really trying not to come down too hard here. I assume on some level it is my fault and that the documentation isn't clear enough / having the GitHub issues isn't enough / etc. Maybe even the prompts need to tell you "don't use the default ports"? I'm not even really sure, but I think originally we all assumed this bug would be fixed so it was temporary. It hasn't been and it doesn't look like it will be, so further action may need to be taken.

Any frustration you're sensing from me is not personally directed toward you but is due to the fact that this has been going on for so long and there's nothing I can really do to fix it. All I can try to do is figure out the best way to help you guys avoid it and that is the hard / frustrating part when Microsoft isn't fulfilling their obligations! There has to be more I can do though, even maybe adding the warnings / prompts in way more prominent / visible places would help 50% of people avoid this issue. I'm definitely open to ideas / suggestions for that.

Hopefully that helps!