I have a device running Syncthing smoothly, meaning that the port (22000) is automatically mapped (as I can see in the router interface). And the direct connection from other devices to this one works as well (even if the second device did not map a port itself).
When I run the syncthing-relay however, it fails with
and indeed the ports (22067 and 22070) do not appear in the router interface.
Mapping the ports manually through something like:
upnpc -e strelay1 -a “$ip” 22070 22070 TCP 3600
upnpc -e strelay2 -a “$ip” 22067 22067 TCP 3600
(upnpc is from the miniupnpc package)
makes it work as expected (AFAICT).
I would have expected both syncthing and strelay to succeed and fail the same, however it seems that the logic to map the ports is different. Is that the case? Shouldn’t they behave the same?
Note that due to my hackish network configuration (I use a second router as a relay between my device and the main router where the mapping has to occur), upnpc still returns an error at the end and fails to check that the mapping is indeed there:
GetSpecificPortMappingEntry() failed with code 606 (Action not authorized)
The relay code has changed very little in a long time, and generally assumes living on a globally reachable address I think. It’s totally possible that it lacks a lot of NAT tricks present in Syncthing.
I guess if it works in syncthing, then it’s logs there are not really interesting.
The relay does print a message if it timed out.
Syncthing is however more reactive, as in, the mapping might take a long time or multiple attempts to acquire, but when it does, it reannounces itself to discovery servers, because it can function without it for other purposes.
Relay on the other hand needs to know this ahead of time to register itself with the pool, so it waits 12 seconds by default, if it didn’t get the UPnP mapping, then proceeds without one.
Ok I see. My question then, or maybe “feature request”, would be: shouldn’t the relay’s UPnP mapping have the same successes and failures as the one in Syncthing? That would make it much more easier to have relays running on devices that are not on 24/7.
They could, but I think you should get the logs from the relay to understand why whats happening in the first place. Also, taking more than 2 seconds to get a port mapping sounds weird.
You can always setup a static port forward on the router to get to work reliably as well.