spring-websocket

What are the pitfalls of using Websockets in place of RESTful HTTP?

痴心易碎 提交于 2019-11-27 11:11:52
I am currently working on a project that requires the client requesting a big job and sending it to the server. Then the server divides up the job and responds with an array of urls for the client to make a GET call on and stream back the data. I am the greenhorn on the project and I am currently using Spring websockets to improve efficiency. Instead of the clients constantly pinging the server to see if it has results ready to stream back, the websocket will now just directly contact the client hooray! Would it be a bad idea to have websockets manage the whole process from end to end? I am

Where “user” comes from in convertAndSendToUser works in SockJS+Spring Websocket?

倖福魔咒の 提交于 2019-11-27 10:34:37
问题 I would like to understand how convertAndSendToUser works in Spring SockJS+Websocket framework. In client, we would connect as stompClient.connect(login, password, callback()) which will result in connect request with "Stomp credentials" of login and password, that can be seen e.g. if we handle SessionConnectEvent http://www.sergialmar.com/2014/03/detect-websocket-connects-and-disconnects-in-spring-4/ But it remains unclear to me whether this will be the "user" meant in server-side send

How WebSocket server handles multiple incoming connection requests?

我是研究僧i 提交于 2019-11-27 10:17:53
According to here : The HTTP Upgrade header requests that the server switch the application-layer protocol from HTTP to the WebSocket protocol . The client handshake established a HTTP-on-TCP connection between IE10 and server. After the server returns its 101 response, the application-layer protocol switches from HTTP to WebSockets which uses the previously established TCP connection. HTTP is completely out of the picture at this point. Using the lightweight WebSocket wire protocol, messages can now be sent or received by either endpoint at any time. So, my understanding is, after the 1st

Shall I use WebSocket on ports other than 80?

拥有回忆 提交于 2019-11-27 09:50:05
问题 Shall I use WebSocket on non-80 ports? Does it ruin the whole purpose of using existing web/HTTP infrastructures? And I think it no longer fits the name Web Socket on non-80 ports. If I use WebSocket over other ports, why not just use TCP directly? Or is there any special benefits in the WebSocket protocol itself? And since current WebSocket handshake is in the form of a HTTP UPGRADE request, does it mean I have to enable HTTP protocol on the port so that WebSocket handshake can be

I get a status 200 when connecting to the websocket, but it is an error?

末鹿安然 提交于 2019-11-27 07:48:16
My error shows up in the console of my browser: "WebSocket connection to 'ws://localhost:32768/DspClusterWebServices/myHandler' failed: Unexpected response code: 200" I am using Spring Websockets 4.1.5 and Tomcat 8.0.18 . My WebSocketConfigurer implementation class looks like: @Configuration @Controller @EnableWebSocket public class WebSocketConfig implements WebSocketConfigurer { class MyHandler implements WebSocketHandler { @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { System.out.println("afterConntectionEstablished called"); } ...implements

Spring WebSocket @SendToSession: send message to specific session

邮差的信 提交于 2019-11-27 02:43:26
Is it possible to send a message to specific session? I have an unauthenticated websocket between clients and a Spring servlet. I need to send an unsolicited message to a specific connection when an async job ends. @Controller public class WebsocketTest { @Autowired public SimpMessageSendingOperations messagingTemplate; ExecutorService executor = Executors.newSingleThreadExecutor(); @MessageMapping("/start") public void start(SimpMessageHeaderAccessor accessor) throws Exception { String applicantId=accessor.getSessionId(); executor.submit(() -> { //... slow job jobEnd(applicantId); }); }

Spring Websockets @SendToUser without login?

风流意气都作罢 提交于 2019-11-27 01:53:25
问题 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

How to find all users subscribed to a topic in spring websockets

谁说胖子不能爱 提交于 2019-11-27 00:56:48
问题 When making something like a chat application using Spring Websockets, it is useful to know who all is subscribed to any given topic. For, e.g. presence data displayed in the clients. I know that I can implement ApplicationListener and keep my own list of "connected users", but it seems like the library must already be doing this work. What's the recommended way to get active subscription info from the library directly (and without maintaining my own list in memory or db). 回答1: You're right,

SockJS receive stomp messages from spring websocket out of order

跟風遠走 提交于 2019-11-26 16:32:20
问题 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). 回答1: Found the root

I get a status 200 when connecting to the websocket, but it is an error?

痞子三分冷 提交于 2019-11-26 13:49:31
问题 My error shows up in the console of my browser: "WebSocket connection to 'ws://localhost:32768/DspClusterWebServices/myHandler' failed: Unexpected response code: 200" I am using Spring Websockets 4.1.5 and Tomcat 8.0.18 . My WebSocketConfigurer implementation class looks like: @Configuration @Controller @EnableWebSocket public class WebSocketConfig implements WebSocketConfigurer { class MyHandler implements WebSocketHandler { @Override public void afterConnectionEstablished(WebSocketSession