SockJS ile Websockets üzerinden STOMP kullanarak ve Full Duplex iletişim ile mobil cihazları bağlamak için JWT'yi kullanarak bir Rest Endpoint kullanarak Stateless Spring (4.2.4.RELEASE) çözümü yapıyorum. Bir Web Sunucusu olarak Tomcat 8.0.33 kullanıyorum ve sockjs javascript istemcisi ile html kullanarak test ediyorum. Stomp protokolü, http yedeğini kullanarak iyi çalışır ancak bunu sadece bir web protokolü protokolü ile yapamıyorum. CORS'i birçok yönden denedim ancak Tomcat Problemi veya sadece kötü yay konfigürasyonu olduğundan emin değilim. Hatta htmlimi aynı alanda ve portta test ettim ve SockJS hala xhr veya iframe'lere geri dönüyor.SockJS ve Tomcat üzerinden STOMP üzerinden Bahar, Websockets'a yükseltilmiyor
WebScoketConfig.java
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer
{
@Override
public void registerStompEndpoints(StompEndpointRegistry registry)
{
RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
registry.addEndpoint("/ws").setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
.setAllowedOrigins("*").withSockJS().setSessionCookieNeeded(false)
.setStreamBytesLimit(512 * 1024)
.setHttpMessageCacheSize(1000)
.setDisconnectDelay(30 * 1000);
}
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
registration.taskExecutor().corePoolSize(50);
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry)
{
registry.enableSimpleBroker("/queue/", "/topic/");
// registry.enableStompBrokerRelay("/queue/", "/topic/");
registry.setApplicationDestinationPrefixes("/myapp");
}
public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
registration.setMessageSizeLimit(500 * 1024);
registration.setSendBufferSizeLimit(1024 * 1024);
registration.setSendTimeLimit(20000);
}
}
WebSecurityConfig.java
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http) throws Exception
{
http.csrf().disable()
.authorizeRequests()
.antMatchers("/**").permitAll();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{
}
}
En son Tomcat sürümünü kullanıyorum. Websockets için destek var. – cardeol