I'm having some troubles running a simple application using Spring WebSockets 4.1.6, Tomcat 7.0.54 and Apache 2.4.16 as Web Server.
I have read a lot of posts in internet, and I don't know what's happening. The server starts without problems. I have an index.html published in my server project that starts a WebSocket connection.
If I access to this file directly from Tomcat, it works perfectly.
http://localhost:8080/myserver/messaging/index.html
But if I access to this file from Apache Server, it doesn't work.
http://localhost/messages/messaging/index.html
In my Apache Server I have configured a proxy pass:
ProxyPass /messages http://localhost:8080/myserver
ProxyPassReverse /messages http://localhost:8080/myserver
My server WebSocket configuration looks as follows:
@Configuration
@EnableWebSocketMessageBroker
public class PuiWebSocketConfig extends
AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.setApplicationDestinationPrefixes("/app");
config.enableSimpleBroker("/user", "/topic");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/puimessaging").withSockJS();
}
}
And my client does the connection as follows:
function connect() {
var socket = new SockJS('/server/puimessaging');
var stompClient = Stomp.over(socket);
var headers = {
puiSessionId : 'a1234567890z'
};
stompClient.connect(headers, function(frame) {
setConnected(true);
stompClient.subscribe('/user/a1234567890z/response', function(data) {
...
});
});
}
The server throws an error saying that I need to enable Async support, but I don't know what to do.
Async support must be enabled on a servlet and for all filters involved
in async request processing. This is done in Java code using the Servlet
API or by adding "<async-supported>true</async-supported>" to servlet and
filter declarations in web.xml. Also you must use a Servlet 3.0+ container
I tried to add the property on my web.xml file, but it doesn't work:
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Any idea?
Thanks in advance.
Marc