1

午後の皆さん。sockjs と Spring4 に問題があります。セットアップのどちら側が問題を引き起こしているのかわかりません。問題は、IE8 が HTTPS 経由で Spring バックエンドへの接続を開くことができないように見えることです。

私はこの例を実装しようとしています: https://demo.rasc.ch/spring4ws/ 私がしようとしているリンクはチャットです。彼のソースへのリンクはこちら: https://github.com/ralscha/spring4ws-demos

彼のソースに加えた唯一の変更は、stomp.min.js ではなく、jquery-1.9.1、Spring 4.0.0、および完全な stomp.js を使用していることです。

チャット クライアントのインデックス ページの sock and stomp コードは次のとおりです。 )[0];

      function notify(text) {
          $('<p class="message notice"/>').text(text).appendTo(content);
              content.scrollTop = content.scrollHeight;
      }

      $(input).keyup(function(event) {
          if (event.which === 13 && $.trim(input.value)) {
              if (!username) {
                 username = input.value;
                 $("#editor p").addClass("user").removeClass("guide").text(username);

                var path = window.location.pathname.substring(0,
                window.location.pathname.lastIndexOf('/')+1);

                var sock = new SockJS(path + 'chat');
                stompClient = Stomp.over(sock);

                stompClient.connect({}, function(frame) {
                     notify("The connection has been opened");
                     $(input).removeAttr("disabled").focus();

                     stompClient.subscribe("/queue/chatmessage", function(msg) {
                           var data = JSON.parse(msg.body);

                           if (lastUsername !== data.username) {
                              lastUsername = data.username;

                              $('<p class="user"/>').text(data.username).appendTo(content);
                }

                 $('<p class="message"/>').text(data.message).appendTo(content);
                 content.scrollTop = content.scrollHeight;

            });
        },
function(error) {
     notify("An error occured: " + error);
     $(input).attr("disabled", "disabled");
  });
} else {
  stompClient.send("/queue/chatmessage", {}, JSON.stringify({username: username, message: input.value}));
}
 input.value = "";
}
});
$(input).focus();
$(window).resize(function() {
$(content).height($(window).height() - $("#editor").outerHeight(true) - 15).scrollTop(content.scrollHeight);
}).resize();
});

整形でごめんなさい。

春に私がしたことは、webconfig Javaファイルを2つのファイルに分けることだけでした

WebConfig は標準です。WebMvcConfigurerAdapter を拡張します。

@Override
public void addViewControllers(ViewControllerRegistry registry) {
  registry.addViewController("/").setViewName("index.html");
}

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
 configurer.enable();

}

WebSocket は WebSocketMessageBrokerConfigurer を実装します。

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
  registry.addEndpoint("/chat").withSockJS().setSessionCookieNeeded(false);
}

@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
  registry.enableSimpleBroker("/queue/");
}

@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
  // use default thread pool with 1 thread
} 

@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
  registration.taskExecutor().corePoolSize(2).maxPoolSize(3);
}

初期化子も基本です。

@Override
protected Class<?>[] getServletConfigClasses() {
  return new Class<?>[] { WebConfig.class, WebSocketConfig.class };
}

@Override
protected String[] getServletMappings() {
  return new String[] { "/chatdemo/*" };
}

また、Eclipseを使用してTomcat 7でこれを実行しています。埋め込まれたTomcatではありません。

私が抱えている問題は、IEでsock内のreadystateが永続的に設定されていることです。私は xhr/xdr ポーリングを完全には理解していませんが、それが問題だと思います。

sockjs 側または spring 側で IE を https 経由で動作させるために他に必要なことはありますか?

4

0 に答える 0