Skip to content

fix(register): report the bound server port for gateway instance identity (#7732) - #7861

Merged
Aias00 merged 1 commit into
apache:masterfrom
markjoin123:cursor/bound-server-port-7732-3715
Oct 20, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
markjoin123:cursor/bound-server-port-7732-3715

Conversation

@markjoin123

Copy link
Copy Markdown
Contributor

Fixes #7732

Gateway instance identity now uses the port the application server actually bound, including when server.port=0. The separate management listener is ignored, and nothing is published until a positive application port is observed.

  • Independent heartbeat keeps its single scheduler and skips reports until WebServerInitializedEvent supplies a positive application port. Shutdown still cancels that scheduler, and a later initialization event does not start another one.
  • Websocket sync defers client creation until that port is known, so the ClientPort handshake header is the bound port.
  • HTTP long polling omits X-Real-PORT until the bound port is known. Admin ignores a missing, zero, or non-numeric client port instead of publishing an empty identity.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

…tity (apache#7732)

Heartbeat, websocket sync, and HTTP long polling wait for the application
server's bound port and ignore the management listener. server.port=0 is
reported as the ephemeral port that was actually bound, and a missing or
non-positive client port is not published.

Fixes apache#7732

Co-authored-by: markxu <[email protected]>
@Aias00

Aias00 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

pls add my wechat: aias00

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change. Reporting the actually-bound listener port instead of the configured server.port (which can be 0 for ephemeral ports) is the correct fix for #7732, and centralizing the rule in BoundServerPort.resolve(...) keeps the heartbeat reporter, HTTP long-polling, and websocket sync consistent.

Highlights:

  • Replacing the ServerProperties-injected port with a WebServerInitializedEvent listener that captures the real bound port is the right approach; the closed guard correctly lets shutdown win over a late init event.
  • Good defensive handling: the management namespace and non-positive ports are rejected, and HTTP long-polling now omits X-Real-PORT entirely when no port is known rather than sending a placeholder 0.
  • The new BoundServerPortTest, HeartbeatBoundPortTest, HttpSyncBoundPortTest and WebsocketBoundPortTest, plus the updated existing suites, give solid coverage of the ephemeral / fixed / management cases.
  • Adding spring-boot as a provided dependency in shenyu-sync-data-http/pom.xml correctly makes the newly used WebServerInitializedEvent import explicit.

CI is green (pr_build passing). Approving.

@Aias00
Aias00 merged commit e09eb35 into apache:master Oct 20, 2026
55 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Gateway instance reporting uses configured port instead of the bound server port

3 participants