jacek.leszczynski
jacek.leszczynski

Reputation: 21

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.

My setup: 2 instances of spring boot app. Single external RabbitMQ broker.

@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. 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?

Upvotes: 2

Views: 1608

Answers (1)

Sophon Men
Sophon Men

Reputation: 319

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

 .setUserDestinationBroadcast("/topic/unresolved.user.dest")
 .setUserRegistryBroadcast("/topic/registry.broadcast")

Upvotes: 2

Related Questions