SockJS与IE8的安全连接

时间:2014-02-21 17:02:34

标签: spring stomp sockjs

下午大家。我遇到了sockjs和Spring4的问题。我不知道设置的哪一方导致了问题。问题是我似乎无法让IE8通过HTTPS打开与Spring后端的连接。

我试图哄骗这个例子:https://demo.rasc.ch/spring4ws/ 我尝试的链接是聊天。 链接到他的来源是:https://github.com/ralscha/spring4ws-demos

我对他的来源做出的唯一改变是我使用的是jquery-1.9.1,Spring 4.0.0和完整的stomp.js而不是stomp.min.js

聊天客户端的索引页面中的sock和stomp代码是:         $(function(){           var username,lastUsername,stompClient,content = $(" #content")[0],           input = $(" #editor input")[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();
});

抱歉格式化。

在Spring中,我所做的就是将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 implaments 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中被设置为永久性。我不完全理解xhr / xdr民意调查,但我认为这是问题所在。

我还需要做些什么才能让IE在sockjs方面或弹簧方面通过https工作?

0 个答案:

没有答案
相关问题