Skip to content

strelaysrv failing to join pool when using -ext-address with an IP alias #10658

Closed

Description

@wwwutz

What happened?

We run a relay server on a linux server where the relay address (141.14.27.108 srspub) is a IP alias on the hosts network interface with IP (141.14.18.14 elwood). The hosts IP is completely blocked for incoming traffic via external firewall. The IP alias however is punched through for TCP 443/22070. On the host we use port forwarding via iptables redirecting inbound traffic on port 443 to local port 43443.
This allows the relay server to run as non-root on 43443 (port mapping is done elsewhere).

This setup works fine for relay clients, but the relay consistently failed to join the public pool with

2026-04-23 11:47:34 INF 2026/04/23 11:47:34 pool.go:95: Failed to join https://relays.syncthing.net/endpoint: request or check error
2026-04-23 11:47:34 INF 2026/04/23 11:47:34 pool.go:96: Response data: getting invitation: incorrect response code 1: not found

strelaysrv is started this way:

strelaysrv -ext-address=srspub.molgen.mpg.de:443 -status-srv=srspub.molgen.mpg.de:22070 -listen=srspub.molgen.mpg.de:43443 -keys=/project/syncthing/srspub.molgen.mpg.de/keys -provided-by=molgen.mpg.de -protocol=tcp4 -debug

I started monitoring the network for connections to the pool servers via

tcpdump -i net02 host 94.130.221.203 or host 94.130.164.126 or host 157.90.0.173 

and get:

16:31:26.040413 IP elwood.molgen.mpg.de.58980 > fsn-k8s.syncthing.net.https: Flags [S], seq 3771026769, win 42340, options [mss 1460,sackOK,TS val 614982611 ecr 0,nop,wscale 9], length 0
16:31:26.055671 IP fsn-k8s.syncthing.net.https > elwood.molgen.mpg.de.58980: Flags [S.], seq 4065764953, ack 3771026770, win 64900, options [mss 1310,sackOK,TS val 3874092046 ecr 614982611,nop,wscale 7], length 0
16:31:26.055699 IP elwood.molgen.mpg.de.58980 > fsn-k8s.syncthing.net.https: Flags [.], ack 1, win 83, options [nop,nop,TS val 614982626 ecr 3874092046], length 0
16:31:26.077995 IP elwood.molgen.mpg.de.58980 > fsn-k8s.syncthing.net.https: Flags [P.], seq 1:1509, ack 1, win 83, options [nop,nop,TS val 614982648 ecr 3874092046], length 1508

note 'elwood' which is the host. this should be 'srspub'. So strelaysrv uses the host interface and not the alias.

After some clanker hints that boundDialer := &net.Dialer{LocalAddr: laddr} might be set to boundDialer := &net.Dialer{LocalAddr: &net.TCPAddr{IP: laddr.IP}} in main.go. In pool.go the global httpClient should be used as the base for connecting to the pool server. After applying that everything worked fine. All requests got sent from the IP alias, no host IP seen anywhere.

But it still failed to join relays.syncthing.net. Logfile:

2026-04-23 09:46:35 INF 2026/04/23 09:46:35 pool.go:95: Failed to join https://relays.syncthing.net/endpoint: request or check error
2026-04-23 09:46:35 INF 2026/04/23 09:46:35 pool.go:96: Response data: getting invitation: incorrect response code 1: not found

So after a long time of checking our network setup is not the culprit the clanker concluded ( Please excuse me of citing it ):

Let me re-read what the pool server actually expects. The probe sends a ConnectRequest where the peer looks for itself (VEH7JSZ looking for VEH7JSZ). In listener.go, a ConnectRequest for a peer not in outboxes returns ResponseNotFound. But notice the sequence — the pool opens two connections simultaneously:

Connection 1 (port 53071): sends JoinRelayRequest → relay registers VEH7JSZ in outboxes
Connection 2 (port 35531): sends ConnectRequest looking for VEH7JSZ

The problem is connection 2 arrives before connection 1 has been processed — so when the ConnectRequest arrives, VEH7JSZ is not yet in outboxes, and the relay returns ResponseNotFound. The pool sees that and fails the check.
This is a race condition in the pool server's verification logic — but it's been working for other relay operators for years, which means it normally works because the JoinRelayRequest connection is usually processed first. The fact that it's failing for you consistently suggests the two connections are arriving in the wrong order every time.
Look at the log again — connection on port 53071 arrives first, then 35531, but then ConnectRequest comes from 35531 and JoinRelayRequest from 53071. The pool opens both simultaneously and the relay's goroutine scheduling happens to process the ConnectRequest before the JoinRelayRequest registers the peer.
This is a real bug in the relay's listener — it has no ordering guarantee between these two concurrent connections. The fix is to make the ConnectRequest handler retry briefly if the target peer isn't yet in outboxes, rather than immediately returning ResponseNotFound.

The pool server sends a ConnectRequest on one connection while sending JoinRelayRequest on another, both simultaneously. The ConnectRequest handler at line 175-184 does an immediate outboxes lookup with no retry — if the JoinRelayRequest goroutine hasn't written to outboxes yet, it returns ResponseNotFound and the pool fails the check.
The fix is a short retry loop in the ConnectRequest handler so it waits briefly for the peer to appear in outboxes

I have attached the suggested patch for reference:

syncthing.strelaysrv-pool.patch

Syncthing version

v2.0.16

Platform & operating system

linux

Browser version

No response

Relevant log output

Activity

  1. added theissue type on Apr 23, 2026
  2. added
    bug
    needs-triage
    on Apr 23, 2026
  3. calmh commented on Apr 23, 2026

    @calmh
    Member

    Thanks. As is often the case, it's found a nugget of truth in the problem and is way off on the solution. :)

  4. added 4 commits that reference this issue on Apr 24, 2026
    1a7825c
    1f57187
    12d62c7
    03a9b13
  5. added a commit that references this issue on Jun 28, 2026
    a4dadaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions