【发布时间】:2023-10-03 10:24:02
【问题描述】:
我正在尝试将 Spring Security 与 websockets 一起使用。作为一个例子,我正在使用 spring-websocket-chat (https://github.com/salmar/spring-websocket-chat) — 来自谈话“深入研究 websockets”的演示应用程序。在该应用程序中,CookieHttpSessionStrategy 用于存储会话 ID,在身份验证期间存储的 cookie 与 /info 请求一起发送。这是演示通过 sockjs 连接到服务器的代码(此请求发送 cookie)https://github.com/salmar/spring-websocket-chat/blob/master/src/main/webapp/js/services.js。我编写了自己的使用 sockjs 和 stomp 的客户端,但是在 /info 请求期间没有发送 cookie。这是我的代码
$connectButton.click(function () {
var serverHost = $host.val();
console.log("sockjs created");
stomp = Stomp.over(new SockJS(serverHost));
console.log("stomp over");
stomp.connect({},
function () {
console.log("connected");
},
function () {
console.log("error");
})
console.log("pressed");
});
【问题讨论】:
标签: javascript spring-security stomp sockjs spring-websocket