0
votes

I am trying to use RabbitMQ Web STOMP Plugin with Spring boot. I have started the RabbitMQ server with the 15674 port exposed for the http/web-stomp protocol. When I run the Spring boot project, I get the below error

o.s.m.s.s.StompBrokerRelayMessageHandler : TCP connection failure in session system: Transport failure: java.lang.IllegalArgumentException: No enum constant org.springframework.messaging.simp.stomp.StompCommand.HTTP/1.1 400 Bad Request

io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: No enum constant org.springframework.messaging.simp.stomp.StompCommand.HTTP/1.1 400 Bad Request

Below is my pom.xml dependencies

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>io.projectreactor.netty</groupId>
        <artifactId>reactor-netty</artifactId>
        <version>0.8.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.0.33.Final</version>
    </dependency>
</dependencies>

I am using below class as the web socket configurations

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfiguration implements 
WebSocketMessageBrokerConfigurer {

   @Override
   public void configureMessageBroker(MessageBrokerRegistry registry) {
       registry.setApplicationDestinationPrefixes("/app")
               .enableStompBrokerRelay("/topic")
               .setRelayHost("localhost")
               .setRelayPort(15674)
               .setClientLogin("guest")
               .setClientPasscode("guest");
}

   @Override
   public void registerStompEndpoints(StompEndpointRegistry registry) {
       registry.addEndpoint("/websocket").withSockJS();

   }
}

Below is a snapshot from my RabbitMQ Web plugin which shows the exposed ports

enter image description here

Can anyone help with this?

2

2 Answers

1
votes

Your port for relay is wrong. Looks at your plugin config on that screenshot. The STOMP port is 61613. And this one is exactly default one in the StompBrokerRelayRegistration:

public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {

    private String relayHost = "127.0.0.1";

    private int relayPort = 61613;

    private String clientLogin = "guest";

    private String clientPasscode = "guest";

    private String systemLogin = "guest";

    private String systemPasscode = "guest";

Not sure why you have decided to use that http/web-stomp plugin for your application: https://www.rabbitmq.com/web-stomp.html

We talk here about exactly STOMP Broker. Our Spring application is going to be WebSocket proxy over that one. The Web STOMP RabbitMQ plugin is for target WebSocket clients. This is not for server side to relay over STOMP Broker.

0
votes

Just use the port exposed for the STOMP plugin. Everything should work fine. You can as well add these dependencies in your pom.xml

<!-- RabbitMQ Starter Dependency -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

<!-- Following additional dependency is required for Full Featured STOMP Broker Relay -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>