optimizing relay selection (and need for discovery?)

I have a weird network with multiple NAT, So I set up stdiscosrv and strelaysrv on a server which all clients can always reach from the lan and outside. The clients can also move between wide-LANs (locations)

basically, imagine:

  • office A 10.1.0.0/16
  • office A, engineering 10.1.1.0/24
  • office B 10.2.0.0/16
  • office B, engineering 10.2.1.0/24

So i proceed to configure all clients with listen address:

tcp://0.0.0.0:22000,
quic://0.0.0.0:22000,
relay://10.1.0.1/id=ABC, (siteA via lan)
relay://10.2.0.1/id=XYZ, (siteB via lan)
relay://siteA.com?id=ABC,
relay://siteB.com?id=XYZ

(i will probably drop the ‘via lan’ ones)

Meaning they will either reach each other via the same LAN (tcp,quic lines), or via the wide-LAN interface of the relay (10… lines), or via the internet interface of the relay (last two lines).

Is there a way to optimize the setup above? I see they waste a lot of time pinging the internet interface when on the lan just to be refused (as they already have one connection open the relay server drops them… which i think causes the log to print “WARNING: Detected a flip-flopping listener”?)

Should I join those relays somehow? Will clients on relayA connect with clients on relayB without a discovery? (because i see on the GUI they receive all ips/relays when they first talk to the peer)

When clients are on both relays (as they almost always are, one via fast LAN and the other via slow internet) will they correctly pick the faster one of both are in the same LAN or is there risk of wasting internet bandwidth with both clients using the remote relay?

If I use the same relay (or already know the other peers can be reached by either relays), do I even need a discovery? I see the relay/ip info is “forgotten” by the UI on restarts. Is there a way to just say “reach everyone via those relays”

Yes, use only one address for one relay.

They need to know the other client is listening on the relay, via discovery or manual configuration of the device address.

Depends on how big the difference is, relays are ping tested for latency and bucketed into groups.

Configure the relay address manually on the device in question.

All in all, with this much effort I’d rather try to get direct connections working within any given site, and only use a relay for traffic between sites. Then it doesn’t matter where you put the relay and you only need one of them.

Is there a way to just save last IPs from last time? or it must be manual to “stay” between sessions?

our external pipes are not too good, so i was trying to spare them. The ideal solution would be to use DNS and direct clients to the nearest relay, but then it would confuse how it must be reached by clients on the other relay :slight_smile:

Yeah, getting direct connections working within each site and only using relay for cross site connections would help with that.