'Configuring rabbitmq with spring4 stomp and socksjs application

I am having issue with spring 4+Stomp+socks js app. It was working fine with simple message broker but when switch to rabbitmq it is not working and could not solve it with the answer mentioned at Configure External Broker(RabbitMQ) In Spring4+STOMP+SockJS Application

My code is:

<websocket:message-broker application-destination-prefix="/app">
    <websocket:stomp-endpoint path="/hello">
        <websocket:sockjs/>
    </websocket:stomp-endpoint>
    <websocket:stomp-broker-relay prefix="/topic" system-login="guest" system-passcode="guest" client-login="guest"
                                  client-passcode="guest" relay-host="localhost" relay-port="15672"/>
</websocket:message-broker>

Controller:

    @Controller
public class StompController {

    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greetUser(User user) throws Exception {
        Thread.sleep(3000); // simulated delay
        return new Greeting("Hello, " + user.getName() + "!");
    }



}

Js:

function connect() {
            var socket = new SockJS('/hello');
            stompClient = Stomp.over(socket);
            stompClient.connect('guest','guest', function(frame) {
                setConnected(true);
                console.log('Connected: ' + frame);
                stompClient.subscribe('/topic/greetings', function(greeting){
                    showGreeting(JSON.parse(greeting.body).content);
                });
            });
        }

While connecting it is saying:

SEVERE [clientInboundChannel-1] org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler.handleMessageInternal Message broker is not active. Ignoring: [Payload byte[0]][Headers={stompCommand=CONNECT, stompCredentials=[PROTECTED], nativeHeaders={heart-beat=[10000,10000], passcode=[PROTECTED], login=[guest], accept-version=[1.1,1.0]}, simpMessageType=CONNECT, simpSessionAttributes={}, simpSessionId=ih_04mxa, id=d36fc1c1-e00c-fb48-51af-c526e3018e20, timestamp=1413617272621}]

I have even enabled stomp plugin in rabbit mq.



Solution 1:[1]

STOMP port

I think Spring can't connect to your RabbitMQ instance because you're pointing it to port 15672, which I think must be the default port for the web UI or something else. The default port for the STOMP connector with rabbitMQ is 61613 (and indeed this is the default value chosen by Spring). Could you try with that one?

Access Control

Also, you should definitely think about your access control configuration, as the guest user won't work remotely.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brian Clozel