Issue when using SRV records
- Dominant language
- Go
- Stars
- 926
- Forks
- 72
- Avg merge
- 20h 14m
- Merged PRs (30d)
- 15
Description
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):

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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the Docker Swarm SRV setup described in the issue and compare the hostname used for the server-list status request with the hostname used for connection routing, using the reported logs as the baseline. Done means determining whether mc-router should handle both hostnames automatically and documenting or validating the expected behavior without relying on a duplicate mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100