[英]Spring Boot websocket RabbitMQ STOMP relay broker cannot send message when sent from instance without TCP connection to client
I've got this issue when I try to send websocket message from the instance that has no TCP connection to client.当我尝试从没有 TCP 连接到客户端的实例发送 websocket 消息时,我遇到了这个问题。
My setup: 2 instances of spring boot app.我的设置:spring 启动应用程序的 2 个实例。 Single external RabbitMQ broker.
单个外部 RabbitMQ 代理。
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.setApplicationDestinationPrefixes("/app");
config.enableStompBrokerRelay("/topic/", "/queue/", "/exchange/")
.setRelayHost(properties.getRelayHost())
.setRelayPort(properties.getRelayPort())
.setSystemLogin(properties.getRelaySystemLogin())
.setSystemPasscode(properties.getRelaySystemPassword())
.setClientLogin(properties.getRelayClientLogin())
.setClientPasscode(properties.getRelayClientPassword())
.setUserDestinationBroadcast(properties.getUserDestinationBroadcast())
.setUserRegistryBroadcast(properties.getUserRegistryBroadcast());
}
Client connected to instance-1, messages sent from instance-1 are sent to client correctly.客户端连接到 instance-1,从 instance-1 发送的消息正确发送到客户端。 When message is sent from instance-2 I get the user session from
SimpUserRegistry
, but sending message fails with: No TCP connection for session...
Am I doing something wrong here or what could be the issue?当从 instance-2 发送消息时,我从
SimpUserRegistry
获得用户 session ,但发送消息失败,并显示: No TCP connection for session...
或者我在这里做错了什么?
You are missing some configuration您缺少一些配置
registry.setApplicationDestinationPrefixes("/app")
.enableStompBrokerRelay("/topic", "/queue")
.setAutoStartup(Boolean.TRUE)
.setClientLogin(username)
.setClientPasscode(password)
.setSystemLogin(username)
.setSystemPasscode(password)
.setUserDestinationBroadcast("/topic/unresolved.user.dest")
.setUserRegistryBroadcast("/topic/registry.broadcast")
.setRelayHost(relayHost)
.setRelayPort(relayPort);
Just adding 2 more configuration properties, It works perfectly for me, no need to work around只需添加 2 个配置属性,它对我来说非常有效,无需解决
.setUserDestinationBroadcast("/topic/unresolved.user.dest")
.setUserRegistryBroadcast("/topic/registry.broadcast")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.