spring-websocket

How to reject topic subscription based on user rights with Spring-websocket

一笑奈何 提交于 2019-11-28 16:33:42
I'm implementing a version of the stock application where the server able to reject topic subscription for certain topic based on the user rights. Is there a way in spring-websocket to do this? For example: In the stock example project we have price topic for 3 instrument: Apple, Microsoft, Google And have two user: User1, User2 User1 should have access to Apple and Microsoft User2 should have access to Google only If User1 subscribe to Google he should got rejected response, and message shouldn't broadcast to him afterwards. tomikiss Thanks to Rossen Stoyanchev answer on github I was manage

Spring Websocket in a tomcat cluster

ぐ巨炮叔叔 提交于 2019-11-28 16:30:49
问题 In our current application, we use Spring Websockets over STOMP. We are looking to scale horizontally. Are there any best practices on how we should handle websocket traffic over multiple tomcat instances and how can we maintain session info across multiple nodes.Is there a working sample that one can refer to? 回答1: Your requirement can be divided into 2 sub tasks: Maintain session info across multiple nodes: You can try Spring Sessions clustering backed by Redis (see: HttpSession with Redis)

Does Spring @SubscribeMapping really subscribe the client to some topic?

爱⌒轻易说出口 提交于 2019-11-28 16:22:47
I am using Spring Websocket with STOMP, Simple Message Broker. In my @Controller I use method-level @SubscribeMapping , which should subscribe the client to a topic so that the client would receive the messages of that topic afterwards. Let say, the client subscribes to the topic "chat" : stompClient.subscribe('/app/chat', ...); As the client subscribed to "/app/chat ", instead of "/topic/chat" , this subscription would go to the method which is mapped using @SubscribeMapping : @SubscribeMapping("/chat") public List getChatInit() { return Chat.getUsers(); } Here is what Spring ref. says: By

Spring Websockets @SendToUser without login?

旧城冷巷雨未停 提交于 2019-11-28 08:25:34
I have a simple spring application with websocket functionality and everything works so far. Now I want to send a message from my server to a specific client using the @SendToUser annotation. This gives me the error "Ignoring message, no principal info available". I understand that i have no login whatsoever on my server, so every user is "anonymous" and does not have a principal (I am not using spring security for now). But every user has a session-id. Isnt it possible to use the session id somehow to differentiate between users? How can i achieve that so my users get a principal which

Stomp over websocket : The send buffer size exceeded the allowed limit

元气小坏坏 提交于 2019-11-28 03:40:01
问题 At client side I am using Stomp for websocket connection and server side I am using Spring 4 It client side I did configuration as var socket = new SockJS(urlBase + "/" + contextroot+'/hello'); stompClient = Stomp.over(socket); Below code executed for every 2 second to send data to server stompClient.send('/app/sendRequest/'+indexVal, {}, JSON.stringify({index : simIndex})); Server respond to below queue stompClient.subscribe('/queue/response', processResponseObj); at server side

SimpMessagingTemplate not sending messages to websocket

爷,独闯天下 提交于 2019-11-28 01:15:36
问题 I have the following contoller @Controller public class GreetingController { @MessageMapping("/hello") @SendTo("/topic/greetings") public Person greeting(String message) throws Exception { Person person=new Person(); person.setAge(10); return person; } @Autowired private SimpMessagingTemplate template; @RequestMapping(path="/meeting",method=RequestMethod.POST) public @ResponseBody void greet() { this.template.convertAndSend("/topic/greetings", "message"); } } and my configuration is

Is it possible to send binary data with STOMP over WebSockets using Spring-WebSockets?

青春壹個敷衍的年華 提交于 2019-11-27 16:27:32
问题 I am able to send and receive JSON with STOMP over WebSockets following spring documentation. However performance is poor at large high rates, so I wish to profile the use of binary messages. Spring-WebSockets 4.0 JavaScript client running in Chrome 35 stomp.js 1.7.1 Sending I send messages using SimpMessageTemplate with the necessary broker relay - see spring documentation @Controller public class DemoBinaryController { @Autowired private SimpMessagingtemplate template @Scheduled(fixedDelay

Spring Boot Websockets in Wildfly

可紊 提交于 2019-11-27 15:38:09
问题 Hi I need to deploy my Spring Boot app into Wildfly 8.1 and I'm getting the following exception: Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:219) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)

SockJS receive stomp messages from spring websocket out of order

自闭症网瘾萝莉.ら 提交于 2019-11-27 14:09:48
I am trying to streaming time series data using Springframework SimpMessagingTemplate (default Stomp implementation) to broadcast messages to a topic that the SockJS client subscribed to. However, the messages is received out of order. The server is single thread and messages are sent in ascending order by their timestamps. The client somehow received the messages out of the order. I am using the latest release version of both stompjs and springframework (4.1.6 release). Found the root cause of this issue. The messages were sending in "correct" order from the application implementation

Disconnect client session from Spring websocket stomp server

China☆狼群 提交于 2019-11-27 12:56:18
问题 I've searched quite a bit and been unable to find this: Is there a way that a spring websocket stomp server can disconnect a client based on the sessionId (or really based on anything at all)? It seems to me that once a client connects to a server there is nothing that allows the server to disconnect the client. 回答1: As far as I know the API doesn't provide what you are looking for, on server-side you can only detect disconnect events. If you want to disconnect a certain client I think you