I have created test project according to tutorial
@Configuration
@EnableWebSocketMessageBroker
public class WSConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/chat");
registry.addEndpoint("/chat").withSockJS();
}
@Controller
public class WSController {
@MessageMapping("/chat")
@SendTo("/topic/messages")
public String send(String message) throws Exception {
return "test";
}
}
I am struggling to connect with postman, I tried different urls:
ws://localhost:8080
ws://localhost:8080/app
ws://localhost:8080/app/chat
each time I click connect button, I get 404 as a response What am I doing wrong? (I am new to websocket)
I was able to connect to the ws://localhost:8080/chat endpoint after following instructions at https://blog.postman.com/postman-supports-websocket-apis/

Note: I also looked at https://spring.io/guides/gs/messaging-stomp-websocket/ for more information on setting up a SpringBoot WebSocket project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With