spring-websocket

Spring 4 WebSockect over STOMP Authentication

与世无争的帅哥 提交于 2019-12-07 15:45:02
问题 I'm developing a multiplayer game based on Spring 4 WebSocket. my server is stateless so in order to identify players i use tokens. after struggling for sometime with how to identify players over WebSockets i came up with this solution: on the client player registers like this: var sockjs = new SockJS("http://mygame/games/", null, {server : token}); this adds the token to the url, I have set up a filter using spring security: String requestURI = request.getRequestURI(); String[] parts =

Why is ServletServerContainerFactoryBean casuing problems when testing?

白昼怎懂夜的黑 提交于 2019-12-07 08:15:14
问题 I'm doing a web application using Spring Boot. This application is also configured to use WebSocket and handle (pretty basic) incoming messages. The application seems to work fine. The problem is when I'm doing some testing. The relevant parts are these: //WebManagerApplication.java @Configuration @ComponentScan @EnableAutoConfiguration public class WebManagerApplication { public static void main(String[] args) { SpringApplication.run(WebManagerApplication.class, args); } } // /

How to add custom headers to STOMP CREATED message in Spring Boot application?

有些话、适合烂在心里 提交于 2019-12-06 21:31:26
I'm trying to add custom headers to the STOMP 'CREATED' message, which is received by client at the first connection. Here is the function which connects to the WebSocket using STOMP JavaScript: function connect() { socket = new SockJS('/chat'); stompClient = Stomp.over(socket); stompClient.connect('', '', function(frame) { whoami = frame.headers['user-name']; console.log(frame); stompClient.subscribe('/user/queue/messages', function(message) { console.log("MESSAGE RECEIVED:"); console.log(message); showMessage(JSON.parse(message.body)); }); stompClient.subscribe('/topic/active', function

How configure the Spring Sockjs Java Client message converters

我怕爱的太早我们不能终老 提交于 2019-12-06 12:19:20
I have one SockJS Java client that use STOMP. Is base on this https://github.com/rstoyanchev/spring-websocket-portfolio/blob/master/src/test/java/org/springframework/samples/portfolio/web/load/StompWebSocketLoadTestClient.java . My code: package mx.intercommunication.websocket.stompclient; import org.springframework.messaging.converter.StringMessageConverter; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.messaging.simp.stomp

Spring Websocket Reply To User Message Flow

被刻印的时光 ゝ 提交于 2019-12-06 11:53:56
问题 I am trying to send a private message between users using spring-websocket. I found the following: https://github.com/rstoyanchev/springx2013-websocket/blob/master/spring-messaging/slides.md which includes: Send Reply To User @Controller public class GreetingController { // Message sent to "/user/{username}/queue/greetings" @MessageMapping("/greetings") @SendToUser public String greet(String greeting) { return "[" + getTimestamp() + "]: " + greeting; } } The above seems to imply that a

Spring 4 Websocket - Nothing happens

纵饮孤独 提交于 2019-12-06 07:01:27
问题 I am learning spring 4 websocket and i will be much thankful if anyone can guide me to learn spring 4 websocket step by step or can suggest some book where i can find step by step practical approach on the said subject. But before that a little help needed here with this snippet that i am trying to execute on eclipse using tomcat 8 . index.html <!DOCTYPE html> <html> <head> <title>Hello WebSocket</title> <script src="https://raw.githubusercontent.com/spring-guides/gs-messaging-stomp-websocket

Java websocket client not working with GDAX sandbox environment

Deadly 提交于 2019-12-06 06:53:36
问题 I am using spring WebSocket WebSocketClient to connect with GDAX server. It is working fine with the Live environment, but the same code is not working with the sandbox environment. Here is my code to connect to the server: public class Test { public static void main(String[] args) throws InterruptedException { String socketURL = "wss://ws-feed.gdax.com"; //Live URL //String socketURL = "wss://ws-feed-public.sandbox.gdax.com"; //sanbox URL, code will not work if you use sandvox URL

Spring websocket security for multiple users

人走茶凉 提交于 2019-12-06 06:51:49
I want to use websocket in spring application for contact requests. I already have setup login page for users and I use spring security for that. My problem is following: how to securely send web socket messages to two different users. I know that i can broadcast messages to every user subscribed to some topic with @SendTo() and can broadcast message to one user only with something like messagingTemplate .convertAndSendToUser(principal.getName(), "/queue/requests", request); because his username is stored in principal. My problem is how to handle when we have to target 2 users from a request

How to combine Spring Security and js sockjs-client

≡放荡痞女 提交于 2019-12-06 04:54:28
问题 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

Whoops! Lost connection to undefined - Connection Lost Just After The Connection Established

大城市里の小女人 提交于 2019-12-06 00:34:55
For Last couple of days i have been trying spring 4 websocket . But There is a problem I am using apache-tomcat-8 and this is not a maven project. Here are my snippets index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>