itzg / mc-router

Routes Minecraft client connections to backend servers based upon the requested server address

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when using SRV records

mcm opened this issue · comments

commented

I'm not actually sure if there's anything the router can do about this, but I figured I'd see if anyone else has run into this. I have DNS setup like so (domain and IP changed to protect the guilty):

image

I have mc-router set up like so (deployed to docker swarm, so tasks.example resolves to the container):

version: "3.8"

services:
...
  router:
    image: itzg/mc-router
    ports:
      - target: 25565
        published: 25565
        mode: host
    networks:
      - minecraft
      - public
    command: --mapping=minecraft.example.com.=tasks.example:25565
...

In the server list in minecraft, the server shows Can't connect to server, but oddly enough the mc-router logs show this:

time="2022-04-10T01:45:18Z" level=info msg="Got connection" client="x.x.x.12:52847"
time="2022-04-10T01:45:18Z" level=warning msg="Unable to find registered backend" serverAddress=example.com
time="2022-04-10T01:45:18Z" level=info msg="Got connection" client="x.x.x.12:52848"
time="2022-04-10T01:45:18Z" level=info msg="Connecting to backend" backendHostPort="tasks.example:25565" client="x.x.x.12:52848" server=minecraft.example.com.
time="2022-04-10T01:45:18Z" level=info msg="Finished relay frontend->backend" amount=0 client="x.x.x.12:52848"
time="2022-04-10T01:45:18Z" level=info msg="Finished relay backend->frontend" amount=0 client="x.x.x.12:52848"

Because of how Minecraft connects (I guess), even though the server list says Can't connect to server, I'm able to connect, because it uses minecraft.example.com. as the server name (from the SRV record). It only uses example.com when trying to refresh the list (which is unfortunate, because it means you can't point multiple SRV records at the same DNS name which points to mc-router, but at least CNAME records are easy).

I'm wondering if there's anything that I'm doing wrong to cause the server list to show Can't connect to server, since mc-router clearly responds affirmatively to the request for minecraft.example.com. but not to the request for example.com.

Let me know if there's more info I can provide for any of this, I hope this is enough information to communicate the setup clearly.

EDIT: I should mention that adding a second mapping for example.com=tasks.example:25565 also works, but I was hoping there's something simpler that I'm missing.

The simpler part is that you don't need to use SRV records when you're using mc-router. Instead just use plain old A records since mc-router is doing the work of multiplexing multiple backend servers from a single port. (SRV work best in cases where a deployed service resides at various IPs and/or various ports.)

your SRV is incorrect
It should be
Name: _minecraft._tcp
Content: 0 25565 minecraft.example.com

You may also need a CNAME record for minecraft.example.com, on top of a SRV record for _minecraft._tcp.minecraft.example.com.

Hope this helps