spring-websocket

Spring websocket: how convert easily the Message<?>'s payload to POJO in ChannelInterceptorAdapter

梦想的初衷 提交于 2019-12-02 08:57:16
I have a Spring App working with websocket I can do the connection and send messages etc. The @Controller is: @MessageMapping("/ws/notification") @SendTo("/topic/springframework.topic.websocket.reply") public NotificationReply handleNotification(Notification notification) { ... } It works fine. Observe the parameter type, Notification , it is a custom object. Now because audit purposes I have the following: @Component public class MessageChannelInterceptorAdapter extends ChannelInterceptorAdapter { @Override public void postSend(Message<?> message, MessageChannel channel, boolean sent) {

Where does @serverendpoint path get mapped (Websockets)

…衆ロ難τιáo~ 提交于 2019-12-02 08:40:36
I have the following @serverendpoint path for a websocket that I am using with the spring framework: @ServerEndpoint(value="/serverendpoint", configurator = SpringConfigurator.class) My first question is say I have a website with the url www.example.com . Where does the serverendpoint with path serverendpoint get mapped? Can I access my serverendpoint at wss://example.com:$PORT/currentpage.html/serverendpoint ? Or is this the wrong way. I have a Wildfly 10 server running. Based on another SO question , I was told to use the following Uri: var wsUri = "wss://" + document.location.hostname + "

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+

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

风流意气都作罢 提交于 2019-12-02 03:56:16
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+"/websock"+temp); //context_path == "/SupportCenter" stompClient = Stomp.over(socket); stompClient

Websocket - InvalidStateError: The connection has not been established yet

爷,独闯天下 提交于 2019-12-02 02:10:44
问题 I'm not able to connect Angular2 front-end with Spring's websocket back-end. Spring configuration xml file: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:websocket="http://www.springframework.org/schema/websocket" xsi:schemaLocation="http://www

Websocket - InvalidStateError: The connection has not been established yet

早过忘川 提交于 2019-12-01 21:51:18
I'm not able to connect Angular2 front-end with Spring's websocket back-end. Spring configuration xml file: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:websocket="http://www.springframework.org/schema/websocket" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www

Spring session + Spring web socket. Send message to specific client based on session id

落爺英雄遲暮 提交于 2019-12-01 21:49:04
I have followed Quetion1 and Quetion2 from stack overflow to send messages to specific client, based on its sessionId but could not find success. Below is my sample RestController class @RestController public class SpringSessionTestApi { @Autowired public SimpMessageSendingOperations messagingTemplate; @MessageMapping("/messages") public void greeting(HelloMessage message, SimpMessageHeaderAccessor headerAccessor) throws Exception { String sessionId = (String) headerAccessor.getSessionAttributes().get("SPRING.SESSION.ID"); messagingTemplate.convertAndSendToUser(sessionId,"/queue/test",message,

How to reply to unauthenticated user in Spring 4 STOMP over WebSocket configuration?

南楼画角 提交于 2019-12-01 05:15:10
问题 I'm experimenting with Spring 4 WebSocket STOMP application. Is there a way to reply to a single unauthenticated user on condition that each user has unique session ID? Right now I can only either broadcast a message or send it directly to an authenticated user. @Controller public class ProductController { @MessageMapping("/products/{id}") @SendTo("/topic") // This line makes return value to be broadcasted to every connected user. public String getProduct(@DestinationVariable int id) { return

Spring STOMP Websockets: any way to enable permessage-deflate on server side?

好久不见. 提交于 2019-11-30 23:35:00
I'm working with spring-websockets under the spring-boot-starter 1.3.1.RELEASE, with the Jetty backend. I am wondering how to enable permessage-deflate in the server. I have a client hosted on a version of Firefox that is willing to negotiate the compression, ie the initial handshake to the WebSocket endpoint includes the compression negotiation header, like: GET https://my-websocket-host/my-endpoint ... Sec-WebSocket-Protocol: v10.stomp,v11.stomp Sec-WebSocket-Extensions: permessage-deflate Sec-WebSocket-Key: ... ... , but the server response does not include the permessage-deflate extensions

How to use Spring WebSocketClient with SSL?

不想你离开。 提交于 2019-11-30 19:16:19
问题 I connect with my websocket client to non-SSL endpoint without any problem. But I cannot find any way how to connect to wss (SSL) endpoint. Where can I define the SSL factory etc. No object seem to have related set method. WebSocketClient transport = new StandardWebSocketClient(); WebSocketStompClient stompClient = new WebSocketStompClient(transport); stompClient.setMessageConverter(new MappingJackson2MessageConverter()); String url = cfg.getWebsocketEndpoint(); StompSessionHandler handler =