stomp

Testing Web Sockets with Jasmine

回眸只為那壹抹淺笑 提交于 2019-12-03 09:45:06
Here is some code that has been written for web-socket using stomp protocol. function WS(url) { var ws = new SockJS('/notifications'); this.client = Stomp.over(ws), this.client.connect('', '', function() { console.log('Connected'); }, function(error) { console.log('STOMP protocol error: ', error.headers.message); }); } WS.prototype.disconnect = function() { }; WS.prototype.subscribe = function() { }; WS.prototype.unSubscribe = function() { }; WS.prototype.send = function(msg) { }; I found this post but it requires actual connection to server, Unit testing Node.js and WebSockets (Socket.io) How

How to get/set the principal and session attributes from Spring 4 stomp websocket methods

二次信任 提交于 2019-12-03 07:14:20
问题 I'm doing experiments with Spring 4 websockets and stomp, and I have a hard time figuring out how to get/set the current user and other session attributes in a message handling method annotated with @MessageMapping . The documentation says that the message handling methods can take a Principal as argument, and I found that the principal is retrieved by Spring by calling getUserPrincipal() on the native socket session, and then associated with the socket session, but I haven't found any way to

How to send ERROR message to STOMP clients with Spring WebSocket?

孤者浪人 提交于 2019-12-03 05:44:42
I am using Spring's STOMP over WebSocket implementation with a full-featured ActiveMQ broker. When users SUBSCRIBE to a topic, there is some permissions logic that they must pass through before being successfully subscribed. I am using a ChannelInterceptor to apply the permissions logic, as configured below: WebSocketConfig.java: @EnableWebSocketMessageBroker public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/stomp") .setAllowedOrigins("*") .withSockJS(); }

Spring Stomp @SendToUser with unauthenticated user not working

六眼飞鱼酱① 提交于 2019-12-03 04:05:43
I'm trying to respond to an unauthenticated user using @SendToUser . Spring 4.1.1 I'm using a newly created Spring Boot application and the only config I have is: @Configuration @EnableWebSocketMessageBroker public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/stomp").withSockJS(); } @Override public void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableSimpleBroker("/topic"); registry.setApplicationDestinationPrefixes("/app"); registry

How to disable debug messages on sockjs- STOMP

大憨熊 提交于 2019-12-03 04:04:42
问题 I have the follow situation: var options = { protocols_whitelist : [ "websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling" ], debug : false }; var socket = new SockJS("/mmyurl/",undefined,options); var stompClient = Stomp.over(socket); stompClient.connect({ company : "XXXXX" }, function(frame) { stompClient.subscribe('/topic/mytopic', function(message){ var myitem = JSON.parse(message.body); }); all works

dynamic message-mapping for websockets in Spring 4

流过昼夜 提交于 2019-12-03 03:48:53
I want to develop a small chat with springs new websocket/stomp support. I guess i cannot use something like this: @MessageMapping("/connect/{roomId}") @SendTo("/topic/newMessage") public String connectToChatRoom(@PathVariable String roomId, Principal p) { return getTimestamp() + " " + p.getName() + " connected to the room."; } What are my options for dynamic mapping here? As a client i want to subscribe only to the room I'm in. Thanks in advance! Figured it out, you need to use @DestinationVariable instead of @PathVariable Yes the @MessageMapping annotation (javaadoc) and the reference docs

How to get/set the principal and session attributes from Spring 4 stomp websocket methods

早过忘川 提交于 2019-12-02 20:48:21
I'm doing experiments with Spring 4 websockets and stomp , and I have a hard time figuring out how to get/set the current user and other session attributes in a message handling method annotated with @MessageMapping . The documentation says that the message handling methods can take a Principal as argument, and I found that the principal is retrieved by Spring by calling getUserPrincipal() on the native socket session, and then associated with the socket session, but I haven't found any way to easily customize this behavior, other than writing a servlet filter and wrap the original request

How to disable debug messages on sockjs- STOMP

无人久伴 提交于 2019-12-02 17:25:21
I have the follow situation: var options = { protocols_whitelist : [ "websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling" ], debug : false }; var socket = new SockJS("/mmyurl/",undefined,options); var stompClient = Stomp.over(socket); stompClient.connect({ company : "XXXXX" }, function(frame) { stompClient.subscribe('/topic/mytopic', function(message){ var myitem = JSON.parse(message.body); }); all works fine, the problem is that on the javascript console is full of debug messages like this: <<< MESSAGE

JBOSS eap 6.3 beta with websocket and stockjs - stomp.js using spring framework

时光怂恿深爱的人放手 提交于 2019-12-02 07:26:25
I'm using jboss eap 6.3 with websocket enabled support, the connection aparently works but in some point of the connection Sock.js throw a 500 server error that looks like: Opening Web Socket... stomp.js:130 XHR finished loading: "http://localhost:8080/frontEnd/track/info". sockjs.js:807 XHR finished loading: "http://localhost:8080/frontEnd/resources/templates/navigation.html". angular.js:8377 WebSocket connection to 'ws://localhost:8080/frontEnd/track/308/fdnevktb/websocket' failed: Error during WebSocket handshake: Unexpected response code: 500 sockjs.js:1213 Web Socket Opened... stomp.js

How to properly configure Stomp and SockJS endpoint in Spring MVC?

筅森魡賤 提交于 2019-12-02 07:04:43
问题 This is/may be duplicate of: Websocket - InvalidStateError: The connection has not been established yet. I am implementing Notification System. And want to initialize Socket connection when user Logged In, and show him his notifications, and also if some event happens. My Code snippet as follows. websocket.js : var stompClient = null; function connect( temp ) { alert(temp); //var socket = new SockJS("/websock"); //var socket = new SockJS("/websock"+temp); var socket = new SockJS(context_path+