sockjs

sockjs+stomp的websocket插件

非 Y 不嫁゛ 提交于 2019-12-05 14:30:03
/** * 依赖文件sockjs.js、stomp.js * */ ;!(function (window) { let WS = function () { this.isConnect = false; //保存所有的订阅事件 {Aevent:[pubfun(status,data),pubfun(status,data),...]} this.subEvents = {}; this.stompClient = null; }; WS.prototype = { constructor: WS //设置连接状态 , setConnect(status) { this.isConnect = status; } //建立连接 , connect(url) { let ws = new SockJS(url) , stompClient = Stomp.over(ws); stompClient.connect({}, (data) => { this.setConnect(true); this.connectSuc.apply(this, [stompClient, data]); }, (error) => { this.setConnect(false); this.connectErr.apply(this,[stompClient,error]); }); this

Websockets, SockJs, Stomp, Spring, RabbitMQ, delete User specific Queues automatically

耗尽温柔 提交于 2019-12-04 13:36:23
问题 i hope someone can help me with this issue: I use the Websocket support of Spring. With SockJs and StompJs i subscribe a queue like this: var socket = new SockJS(localhost + 'websocket'); stompClient = Stomp.over(socket); stompClient.connect('', '', function(frame) { stompClient.subscribe("/user/queue/gotMessage", function(message) { gotMessage((JSON.parse(message.body))); }); }, function(error) { }); This works really fine with the SimpMessageSendingOperations of Spring. BUT there is one big

How to combine Spring Security and js sockjs-client

孤者浪人 提交于 2019-12-04 09:53:12
I want to create a Spring Server and a Broswer javascript client connecting via sockjs-client. The connection should be secured via Spring Security. I have the following dilemma: Spring Security seems to assume that the websocket handshake happens via an authenticated http session (E.g. JSESSIONID cookie set, login happened). sockjs-client however seems to impose the limitation on developers that no authenticated http session must be used (See https://github.com/sockjs/sockjs-client/issues/196 ), enforcing this any way it can. Is my evaluation of the dilemma correct, and is there any obvious

How to secure websocket application [Spring boot + STOMP]

寵の児 提交于 2019-12-04 07:51:59
Good morning, I've created a simple Spring Boot WebSocket application. Right now I would like to set some security to it. I've trying some examples but I cannot get it worked. I'm getting error: web browser: >>> CONNECT ${_csrf.headerName}:${_csrf.token} accept-version:1.1,1.0 heart-beat:10000,10000 <<< ERROR message:Failed to send message to ExecutorSubscribableChannel[clientInboundChannel]; nested exception is org.springframework.security.web.csrf.MissingCsrfTokenException\c Could not verify the provided CSRF token because your session was not found. content-length:0 Log in STS: Failed to

Spring 4 AbstractWebSocketMessageBrokerConfigurer With SockJS Not Negotiating Transport Properly

前提是你 提交于 2019-12-04 06:41:12
So I must say that all of the websocket tutorials/examples appear to be so easy, but it seems you really have to dig to find really important pieces of information that are left out of the simple examples. I'm stil having quite a few issues with my webapp using the Spring 4 Stomp message broker with SockJS on the front end. Currently, if I add an endpoint to the StompEndpointRegistry without enabling SockJS(), then declare my socket on the front end using dojo's dojox/socket, Firefox 28 will open a websocket just fine. However, I need support in IE8 and IE9, so I switched to SockJS. Using

Configure External Broker(RabbitMQ) In Spring4+STOMP+SockJS Application

依然范特西╮ 提交于 2019-12-04 05:32:08
I am working on a chat application developed using Spring4 Messaging and STOMP implemented with SockJS. The application works fine when I use the Simple Message Broker : config.enableSimpleBroker("/queue/", "/topic/"); But, now we have a requirement to use an external broker(RabbitMQ) with the same application. For that, I changed the above code with the following: // config.enableSimpleBroker("/queue/", "/topic/"); config.enableStompBrokerRelay("/queue", "/topic"); My client side is connecting using STOMP client as below: stompClient.connect({}, function(frame) { // subscribe to topics or

ReactJS could not proxy request from localhost:3000 to localhost:3003

你说的曾经没有我的故事 提交于 2019-12-04 04:26:17
I am writing a SPA using create-react-app and am using an expressjs server as my backend. For development I run my frontend test server on port 3000 and my backend expressjs test server on 3003. I make many API calls client side using Axios so for development convenience I have defined proxy: " http://localhost:3003 " in my package.json This works fine on my laptop, but when running on my workstation I constantly get the error when accessing my app: Proxy error: Could not proxy request /sockjs-node/487/wrst1bub/websocket from localhost:3000 to http://localhost:3003/ . See https://nodejs.org

How to send custom message to custom user with spring websocket?

半城伤御伤魂 提交于 2019-12-03 10:58:33
I'm new to spring websocket . I want to send product changes to clients. For this, I want to do it as follows: Client creates a socket connection and subscribes destination: var socket = new SockJS('/websocket'); var stompClient = Stomp.over(socket); stompClient.connect({}, function (frame) { stompClient.subscribe('/product/changes', function (scoredata) { // We received product changes }); }); //Send Ajax request and say server I want to know product with id=5 changes. sendAjaxRequest(5); I've configured spring app as follow: @Configuration @EnableWebSocketMessageBroker public class

Websockets, SockJs, Stomp, Spring, RabbitMQ, delete User specific Queues automatically

倾然丶 夕夏残阳落幕 提交于 2019-12-03 08:28:09
i hope someone can help me with this issue: I use the Websocket support of Spring. With SockJs and StompJs i subscribe a queue like this: var socket = new SockJS(localhost + 'websocket'); stompClient = Stomp.over(socket); stompClient.connect('', '', function(frame) { stompClient.subscribe("/user/queue/gotMessage", function(message) { gotMessage((JSON.parse(message.body))); }); }, function(error) { }); This works really fine with the SimpMessageSendingOperations of Spring. BUT there is one big problem. the Queue name looks like this: gotMessage-user3w4tstcj and its not declared as an auto

Stomp over socket using sockjs can&#039;t connect with Spring 4 WebSocket

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to use Spring 4 WebSocket with STOMP over socket using sockjs. And i faced a problem. My configuration: websocket.xml - part of spring context <websocket:message-broker application-destination-prefix="/app"> <websocket:stomp-endpoint path="/ws"> <websocket:sockjs/> </websocket:stomp-endpoint> <websocket:simple-broker prefix="/topic"/> </websocket:message-broker> Controller code: @MessageMapping("/ws") @SendTo("/topic/ws") public AjaxResponse hello() throws Exception { AjaxResponse ajaxResponse = new AjaxResponse(); ajaxResponse