인터넷을 통해 검색하는 동안 지금까지 배운 내용에서 openshift는 HTTP를 통해 웹 소켓 연결을 여는 데 포트 8000 만 제공합니다.WebSocket 핸드 셰이크 중 오류 : 예기치 않은 응답 코드 : Spring Websocket, Stomp, OpenSock에서 SockJS 사용시
Stomp와 SockJs를 사용하여 스프링 WebSocket을 구현하는 방법은 무엇인지 알 수 없습니다.
function connect() {
var socket = new SockJS('http://jbossews-nabac.rhcloud.com:8000/portal/ws');
stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
setConnected(true);
console.log('Connected: ' + frame);
stompClient.subscribe('/queue/reply/${pageContext.session.id}', function(greeting) {
showGreeting(greeting.body);
});
});
}
웹 소켓 서버 측 Configration : 여기 내 코드,
웹 소켓 클라이언트 측 구현이다
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketDefaultConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic/", "/queue/");
config.setApplicationDestinationPrefixes("/portal");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.withSockJS()
.setInterceptors(httpSessionIdHandshakeInterceptor());
}
@Bean
public HttpSessionIdHandshakeInterceptor httpSessionIdHandshakeInterceptor() {
return new HttpSessionIdHandshakeInterceptor();
}
}
은 내가이 방법을 시도하는 경우,
var socket = new SockJS('/portal/ws');
나는이 얻을
오류,
이 오류를 해결하기 위해 도와주세요.
이 문제를 해결 했습니까? 그렇다면 답을 공유해주십시오. – Debopam