question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stomp client fails to connect to a dynamic controller destination that has a @DestinationVariable when I switch to use a StompBrokerRelay but it works with SimpleBroker

See original GitHub issue

Hi

When I switch the default config example in the project gs-messaging-stomp-websocket to use config.enableStompBrokerRelay("/topic"); the example works as when I had config.enableSimpleBroker("/topic");.

When I change the controller to use dynamic destinations with a SimpleBroker as below, it also works:

@MessageMapping("/hello/{id}")
@SendTo("/topic/greetings/{id}")
 public Greeting greeting(HelloMessage message, @DestinationVariable String id) throws Exception {
      Thread.sleep(1000); // simulated delay
      return new Greeting("Hello, " + message.getName() + " and id passed is " + id);
 }

But if I change the configuration to use Stomp broker with the above controller, my server app logs say:

2017-04-19 00:26:08.354 ERROR 14958 --- [eactor-tcp-io-3] o.s.m.s.s.StompBrokerRelayMessageHandler : Received ERROR {message=[Invalid destination], content-type=[text/plain], version=[1.0,1.1,1.2], content-length=[48]} session=uxmho5lj text/plain payload='/greetings/1' is not a valid topic destination

and the stomp client say:

Opening Web Socket...
stomp.min.js:8 Web Socket Opened...
stomp.min.js:8 >>> CONNECT
cool:something
accept-version:1.1,1.0
heart-beat:10000,10000


stomp.min.js:8 <<< PONG
stomp.min.js:8 <<< CONNECTED
session:session-kN6B9Jl7qyqx-lNHslTsPA
heart-beat:10000,10000
server:RabbitMQ/3.5.7
version:1.1


stomp.min.js:8 connected to server RabbitMQ/3.5.7
stomp.min.js:8 send PING every 10000ms
stomp.min.js:8 check PONG every 10000ms
app.js:20 Connected: CONNECTED
version:1.1
server:RabbitMQ/3.5.7
heart-beat:10000,10000
session:session-kN6B9Jl7qyqx-lNHslTsPA


stomp.min.js:8 >>> SUBSCRIBE
id:sub-0
destination:/topic/greetings/1


stomp.min.js:8 <<< ERROR
message:Invalid destination
content-type:text/plain
version:1.0,1.1,1.2
content-length:48

'/greetings/1' is not a valid topic destination

stomp.min.js:8 <<< PONG
stomp.min.js:8 Whoops! Lost connection to http://localhost:8080/gs-guide-websocket

The same code works with Simple broker but does not work with a StompBrokerRelay. Is there some further settings required for this to work with the same code or could this be an issue in BrokerRelay? I came across this post on stackoverflow and it doesn’t see to work for me.

I added these dependencies when I turned on Broker relay:

        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-net</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.9.Final</version>
        </dependency>

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
rstoyanchevcommented, Apr 20, 2017

That said I did not add a destination variable…

I see the issue now. RabbitMQ does not support “/” as a separator. You can do something like this:

stompClient.subscribe('/topic/greetings.*', function (greeting) {
            // ...
        });
@MessageMapping("/hello/{id}")
@SendTo("/topic/greetings.{id}")
public Greeting greeting(HelloMessage message, @DestinationVariable String id) {
   // ...
}

The above works but if you want spring-messaging to also use “.” as separator for mapping destinations you can customize it.

4reactions
gregturncommented, Apr 20, 2017

@givenm I don’t need both a comment AND a frowny face asking for feedback. I’ve ask Rossen to take a peek, given this is his specialty, but being open source, I can’t promise anything. If you had a support contract, we could certainly escalate. But your alternative would be soliciting Stackoverflow for more community response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring 4 websockets dynamic MessageMapping not executed
This approach is working fine when I am using Simple Broker but fails when I use External Broker(RabbitMQ). It says "invalid destination" in...
Read more >
Using Spring Boot for WebSocket Implementation with STOMP
In this article, I am going to show you how to implement WebSockets with the Spring Boot Framework. I will cover both the...
Read more >
25. WebSocket Support - Spring
This part of the reference documentation covers Spring Framework's support for WebSocket-style messaging in web applications including use of STOMP as an ...
Read more >
Chapter 18. Messaging with WebSocket and STOMP - Spring ...
In this chapter, you'll learn how to achieve asynchronous communication between a server and a browser-based application using Spring's WebSocket features. We' ...
Read more >
WebSockets With Spring, Part 3: STOMP Over WebSocket
STOMP is a streaming protocol because it can work over any reliable ... To connect to a broker, a client sends a CONNECT...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found