admin管理员组文章数量:1390728
I am trying to set up a WebSocket server using Spring Boot and i tried to connect to it using Postman (New Request → WebSocket). However, I keep getting the following error response:
Error: Unexpected server response: 200
This is my WebSocketConfig.java
import .springframework.context.annotation.Configuration;
import .springframework.messaging.simp.config.MessageBrokerRegistry;
import .springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import .springframework.web.socket.config.annotation.StompEndpointRegistry;
import .springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.setAllowedOrigins("*").withSockJS();
;
}
}
This is my security config
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.csrf().disable() //
本文标签:
javaSpring Websocket configurationStack Overflow
版权声明:本文标题:java - Spring Websocket configuration - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1744586674a2614236.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论