I use Java Spring Boot 3.2.0 and spring-boot-starter-websocket The Handshake to connect to the Websocket is successfull, but i cant get my Controller invoked.
Config:
@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfiguration implements WebSocketMessageBrokerConfigurer
{
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/gs-guide-websocket").setAllowedOrigins("*");
}
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
}
Controller:
@Controller
@CrossOrigin(origins = "*")
public class ConnectionController {
@MessageMapping("/audio")
@SendTo("/topic/audio")
public String sendAudio(String message)
{
return "connected: " + message;
}
}
I use a Websocket client to subscribe to the topic like that:
SUBSCRIBE
destination:/topic/audio
and send a message to the Controller like that:
SEND
destination:/app/audio
Test
Why does my controller not get called?
Im using Websocket King as the Client