spring-websocket

Using RabbitMQ stomp adapter to relay message across subscriptions in different servers

你离开我真会死。 提交于 2019-12-24 00:48:48
问题 I am using Spring to setup Stomp server endpoints (extending AbstractWebSocketMessageBrokerConfigurer) @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableStompBrokerRelay("/topic","/queue") .setRelayHost(<rmqhost>); } @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/myapp/websockets").setAllowedOrigins("*"); } The objective is that I can have multiple servers, and a client will connect to any one of

Spring websocket set handshake handler/interceptor

依然范特西╮ 提交于 2019-12-24 00:44:08
问题 I try to set handshake handler through xml config: <bean id="customHandler" class="app.wsock.CustomHandler"/> <websocket:message-broker> <websocket:stomp-endpoint path="/foo"> <websocket:handshake-handler ref="customHandler"/> <websocket:sockjs/> </websocket:stomp-endpoint> <websocket:stomp-broker-relay prefix="/topic,/queue" /> </websocket:message-broker> but on connect also using DefaultHandshakeHandler. What I'm doing wrong? 回答1: This is a bug (see SPR-11568). You'll need to update your

Spring Stomp over Websocket: Stream large files

我与影子孤独终老i 提交于 2019-12-23 21:21:18
问题 My SockJs client in webpage, sends message with a frame size of 16K. The message size limit is what determines the max size of the file that I can transfer. Below is what I found in the doc. /** * Configure the maximum size for an incoming sub-protocol message. * For example a STOMP message may be received as multiple WebSocket messages * or multiple HTTP POST requests when SockJS fallback options are in use. * * <p>In theory a WebSocket message can be almost unlimited in size. * In practice

Spring Websocket Configuration: using WebSocketMessageBrokerConfigurationSupport and WebSocketConfigurer together - how?

只愿长相守 提交于 2019-12-23 19:22:14
问题 I am configuring currently my Spring Websocket using the class public class WebSocketConfig extends WebSocketMessageBrokerConfigurationSupport now I came across the advice Spring STOMP Websockets: any way to enable permessage-deflate on server side? that makes use of public class SampleJettyWebSocketsApplication implements WebSocketConfigurer and overrides @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) and offers @Bean public DefaultHandshakeHandler

Request or Session scope in Spring Websocket

℡╲_俬逩灬. 提交于 2019-12-23 12:13:08
问题 From WebSocket Endpoint I try to call Singleton Service. But I an unable to use Request or Session scope from WebSocket. (@Scope( value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)) I get Scope 'request' is not active for the current thread; For 'request' or 'session' scope on any 'ScopedProxyMode'. Thanks for the help! 回答1: For web sockets there are no request/response so the request scope is invalid. They introduced new scope called websocket in Spring 4.1. @Scope(name =

How to set a Principal within a HandshakeInterceptor

天大地大妈咪最大 提交于 2019-12-23 09:59:06
问题 I'm using a very thin implementation of Spring's WebSockets. WebSocketSession has the method getPrincipal(), but how can I set it from within a HandshakeInterceptor? The method I would like to put the Principal in is: public boolean beforeHandshake(final ServerHttpRequest request, final ServerHttpResponse response, final WebSocketHandler wsHandler, final Map<String, Object> attributes) throws Exception { Principal = getPrincipal(); // Now where to set the principal so it is available in

Webrtc Remote video stream not working

给你一囗甜甜゛ 提交于 2019-12-23 09:57:30
问题 While setting the remoteDescription , I am getting below error in firefox : DOMException [InvalidStateError: "Cannot set remote offer in state have-local-offer" code: 11 nsresult: 0x8053000b location: http://localhost:8080/resources/assets/js/test-online.js:111] Please find below my test-online.js code var localVideo; var remoteVideo; var peerConnection; var serverConnection; var peerConnectionConfig = {'iceServers': [{'url': 'stun:stun.services.mozilla.com'}, {'url': 'stun:stun.l.google.com

Why is SimpUserRegistry not working properly on EC2 Instance

拈花ヽ惹草 提交于 2019-12-23 08:54:06
问题 I am using SimpUserRegistry to get online user-count (with getUserCount() ). And it is working good on my local machines but not on AWS EC2 instances (tried with Amazon Linux and Ubuntu) with just elastic IP and no load balancer. The problem on EC2 is that some users, when connected, are never added to the registry and thus I get wrong results. I have session listeners, for SessionConnectedEvent and SessionDisconnectEvent , where I use the SimpUserRegistry (autowired) to get the user presence

Attribute ServerContainer not found in ServletContext

假如想象 提交于 2019-12-23 04:43:43
问题 In my Spring boot application i use also websockets. Everything works fine, as expected in production. Now i started to create UnitTests with Spring-Boot-Test. Every time i start a @SpringBootTest , i get following exception (shortened): java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'createWebSocketContainer' defined in class path resource [com/package/spring/ws

How to troubleshoot and resolve 404 on SockJs's /info path when with cross-origin

≯℡__Kan透↙ 提交于 2019-12-23 04:42:54
问题 I'm having trouble with SockJs and CORS. I use spring. I set up the WebMvcConfigured as follows: @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry .addMapping("/**") .allowedOrigins("http://localhost:3000") .allowCredentials(true); ; } }; } and WebSocketConfig as follows: @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/topic"); config