클라이언트에서 STOMP를 통해 SockJs (v1.1.1)와 함께 Spring Websocket을 사용하고 있습니다. 아래 코드로 클라이언트를 생성합니다.SockJs가있는 Spring Websocket이 XhR 스트리밍에서 Websocket으로 전환됩니다.
SockJS = require('sockjs-client')
Stomp = require('webstomp-client')
stompClient = Stomp.over(new SockJS(url))
괜찮습니다. 하지만 그것은 기본적으로 전송으로 xhr_streaming
을 사용합니다. 이는 저에게 바람직하지 않습니다. websocket
tranport로 전환하고 싶습니다.
stompClient = Stomp.over(new SockJS(url, null, {transports:'websocket'}))
그러나이 방법은 저에게 적합하지 않습니다.
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractSessionWebSocketMessageBrokerConfigurer<ExpiringSession> {
@Override
public void configureStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/myEndpoint").setAllowedOrigins("*")
.withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/queue/", "/topic/");
registry.setApplicationDestinationPrefixes("/app");
}
}
내가 xhr_streaming
과 얼굴의 주요 문제는 모든 스트림 요청이 사용자 세션에 대한 마지막 액세스 시간 (나는 봄을 사용하는 업데이트이다 :
code: 2000
reason: "All transports failed"
내 봄 웹 소켓 구성이 매우 간단합니다 : 그것은 이벤트와 폭포 세션도). 하지만 내 응용 프로그램에는 바람직한 동작이 아닙니다. 어떻게 해결할 수 있을까요? 그리고 websocket
전송 도움이 될 것인가? 미리 감사드립니다.