Spring WebSockets 4.1.6、Tomcat 7.0.54、および Apache 2.4.16 を Web サーバーとして使用して単純なアプリケーションを実行する際に問題が発生しています。
私はインターネットで多くの投稿を読みましたが、何が起こっているのかわかりません。サーバーは問題なく起動します。WebSocket 接続を開始するサーバー プロジェクトで公開された index.html があります。
このファイルに Tomcat から直接アクセスすると、問題なく動作します。
http://localhost:8080/myserver/messaging/index.html
しかし、Apache Server からこのファイルにアクセスすると、うまくいきません。
http://localhost/messages/messaging/index.html
私のApacheサーバーでは、プロキシパスを構成しました:
ProxyPass /messages http://localhost:8080/myserver
ProxyPassReverse /messages http://localhost:8080/myserver
私のサーバーの WebSocket 構成は次のようになります。
@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();
}
}
そして、私のクライアントは次のように接続します:
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) {
...
});
});
}
サーバーは、非同期サポートを有効にする必要があるというエラーをスローしますが、どうすればよいかわかりません。
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
web.xml ファイルにプロパティを追加しようとしましたが、うまくいきません:
<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>
何か案が?
前もって感謝します。
マルク