spring-websocket

Spring security/Spring session/Web sockets

限于喜欢 提交于 2019-12-23 01:49:31
问题 We are attempting to use a combination of spring session, spring security and websockets to implement security for a websocket API without using cookies. Ideally we would be using a authorization header or authentication using the websocket/stomp messages but this does not seem to be possible with the current spring websocket support. We are using a pre-auth provider to validate a query parameter token and log the user in. I can see that the proper user is pulled out in the pre-auth for the

Spring boot “No active sessions for user destination” after reconnect

徘徊边缘 提交于 2019-12-22 14:14:54
问题 I'm writing a test application using web sockets. Sometimes after a re-connection, Spring Boot v1.5.10.RELEASE does not find a session associated with the user. This problem not reproducible constantly. Test: @Test public void receiveInCycle() throws Exception { for (int i = 0; i < 9999; i++) { receive(); } } public void receive() throws Exception { Collection<Object> payloads = new ArrayList<>(); //create session for "kate" user StompSession stompSession = createStompSession("kate");

Spring 4 websocket + stomp + rabbitmq and clustering

廉价感情. 提交于 2019-12-22 07:51:30
问题 I am going through Spring 4 websocket + stomp + rabbitmq(RabbitMQ-Web-Stomp plugin) architecture and I have a question about clustering. As per my understanding here Spring MVC act as a gateway for STOMP requests. If we cluster the application instance with spring web socket configuration will it create any confusion? For an example will it open multiple listeners and how will in such a case this architecture behave? 回答1: In this scenario, you would need to use load balancing and a message

Spring security websocket and HTTP authentication/authorization

本秂侑毒 提交于 2019-12-22 05:11:59
问题 Summary I would like to implement websocket communication over STOMP. Authenticate The user in the time of the first (HTTP request) websocket handshake and use this Principal for authorizing websocket messages later. Problem The system authenticates the client at the first time when it tries to connect to the websocket endpoint (the time of HTTP handshake). My spring security filter and Authentication provider does its job and authenticates the client properly. After this I can check that the

Spring boot websocket 1.2.1.RELEASE - IllegalArgumentException in bean 'subProtocolWebSocketHandler' : No handlers

£可爱£侵袭症+ 提交于 2019-12-21 22:22:03
问题 So I'm looking to upgrade my projects from spring boot 1.1.9.RELEASE to 1.2.1.RELEASE. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> <version>${spring.boot.version}</version> </dependency> However, on startup, I gained: Exception in thread "Thread-0" org.springframework.context.ApplicationContextException: Failed to start bean 'subProtocolWebSocketHandler'; nested exception is java.lang.IllegalArgumentException: No handlers at

Send STOMP ERROR from Spring Websocket program

五迷三道 提交于 2019-12-21 21:37:29
问题 I have a Spring Websocket Stomp application that accepts SUBSCRIBE requests. In application I have a handler for SUBSCRIBE, that is, @Component public class SubscribeStompEventHandler implements ApplicationListener<SessionSubscribeEvent> { @Override public void onApplicationEvent(SessionSubscribeEvent event) {} } that I use to validate subscription. I would check something in the onApplicationEvent and send STOMP ERROR message back to client from this function. I found this recipe How to send

Spring WebSocket. Get access to Cookie in Config

北慕城南 提交于 2019-12-21 05:40:50
问题 I'm trying to configure WebSocket via Spring with STOMP, OAuth 2 and SockJS. New spec tells us how to implement it using Interceptors. The case is: if user is authenticated there is an Bearer Token in Native header of CONNECT request and there is no problem to set principal via Token. But my task is to use BrowserToken for unauthorized users (which is saved in Cookies). How can i get it from the request? 回答1: I've found a solution: @Override public void registerStompEndpoints

Spring-boot tomcat is able to offer only lesser than 10,000 connections?

断了今生、忘了曾经 提交于 2019-12-21 04:21:31
问题 I am testing the server with spring-boot. However, I got some problems during doing test. my test is How many memories server use with increasing the web socket sessions(the number of client). 1,000 clients(lesser than 9000 sessions) has no issues with doing the test. but, When I tried to test 10k connections, server made connections almost until 10,000.(sometimes creating sessions until 9990, sometimes 9988, 9996 like this, not the specific limit the number of socket) after that, it just

How to send custom message to custom user with spring websocket?

浪子不回头ぞ 提交于 2019-12-21 03:41:05
问题 I'm new to spring websocket. I want to send product changes to clients. For this, I want to do it as follows: Client creates a socket connection and subscribes destination: var socket = new SockJS('/websocket'); var stompClient = Stomp.over(socket); stompClient.connect({}, function (frame) { stompClient.subscribe('/product/changes', function (scoredata) { // We received product changes }); }); //Send Ajax request and say server I want to know product with id=5 changes. sendAjaxRequest(5); I

Webflux websocketclient, How to send multiple requests in same session[design client library]

房东的猫 提交于 2019-12-20 18:46:19
问题 TL;DR; We are trying to design a WebSocket server using spring webflux WebSocket implementation. The server has usual HTTP server operations e.g. create/fetch/update/fetchall . Using WebSockets we were trying to expose one endpoint so the clients could leverage a single connection for all sort of operations, given WebSockets are meant for this purpose. Is it a right design with webflux and WebSockets? Long Version We are starting a project which is going to use reactive web sockets from