I am building a Spring Websocket application that user RabbitMQ as message broker.
The configuration file is provided below
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableStompBrokerRelay("/topic")
.setRelayHost("192.168.1.8")
.setRelayPort(61613)
.setClientLogin("user")
.setClientPasscode("user");
//config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/gs-guide-websocket").setAllowedOrigins("*").withSockJS();
}
}
But when I am running the application it gives me the following error
Received ERROR {message=[Bad CONNECT], content-type=[text/plain], version=[1.0,1.1,1.2],
content-length=[26]} session=_system_ text/plain payload=non-loopback access denied
I have tried to give the required permissions in rabbitmq
sudo rabbitmqctl set_permissions -p / user ".*" ".*" ".*"
But still the problem appears. But the application works fine if I replace the ipaddress in 'setRelayHost(..)' with either 'localhost' or '127.0.0.1'.