Skip to content

Set host header consistently in STOMP relay CONNECT frames#36673

Closed
tianhaocui wants to merge 1 commit into
spring-projects:mainfrom
tianhaocui:fix-stomp-relay-host-header
Closed

Set host header consistently in STOMP relay CONNECT frames#36673
tianhaocui wants to merge 1 commit into
spring-projects:mainfrom
tianhaocui:fix-stomp-relay-host-header

Conversation

@tianhaocui

Copy link
Copy Markdown
Contributor

Closes #36663

StompBrokerRelayMessageHandler only set the host header in CONNECT frames when virtualHost was explicitly configured. Per STOMP 1.2 specification, the host header is required on CONNECT frames.

This change falls back to relayHost (the TCP connection target) when virtualHost is not configured, ensuring the host header is always present in both system session and client session CONNECT frames.

StompBrokerRelayMessageHandler only set the host header in CONNECT
frames when virtualHost was explicitly configured. Per STOMP 1.2, the
host header is required on CONNECT frames.

Fall back to relayHost (the TCP connection target) when virtualHost is
not configured, ensuring the host header is always present in both
system session and client session CONNECT frames.

Closes spring-projects#36663

Signed-off-by: cuitianhao <54015884+tianhaocui@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 19, 2026
@rstoyanchev rstoyanchev self-assigned this Apr 28, 2026
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 28, 2026
@rstoyanchev rstoyanchev added this to the 7.0.8 milestone Apr 28, 2026
@twiedow

twiedow commented Jun 11, 2026

Copy link
Copy Markdown

I don't know if this also lead to problem like mine in other cases: Due to this change, the client could not connect to the external broker (RabbitMQ in my case) and responded with error Virtual host 'localhost' access denied.

RabbitMQ has a standard virtual host configured with name /. The RabbitMQ STOMP docs says that if there is no host set in the headers it defaults to /.

In order to fix this error I have to set the virtual host in the StompBrokerRelayRegistration explicitly to /.

In my eyes this change is a breaking change and should have been mentioned somewhere.

@rstoyanchev

Copy link
Copy Markdown
Contributor

@twiedow could you create a separate issue, and we will address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consistently set host header in StompRelayMessageBrokerHandler

4 participants