1
我正在構建一個用戶RabbitMQ作爲消息代理的Spring Websocket應用程序。使用rabbitmq配置Spring websocket時出現非回送訪問被拒絕錯誤
配置文件提供以下
@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();
}
}
但是,當我運行的應用程序它給了我下面的錯誤
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
我曾試圖給出所需的權限RabbitMQ的
sudo rabbitmqctl set_permissions -p/user ".*" ".*" ".*"
但仍然出現問題。但是,如果我將'setRelayHost(..)'中的ipaddress替換爲'localhost'或'127.0.0.1',則應用程序可以正常工作。
您是否解決了此問題? – pranag