spring-websocket

Send STOMP ERROR from Spring Websocket program

隐身守侯 提交于 2019-12-04 15:26:59
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 ERROR message to STOMP clients with Spring WebSocket? but I need to understand how to get

Java websocket client not working with GDAX sandbox environment

南楼画角 提交于 2019-12-04 14:07:44
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 WebSocketClient client = new StandardWebSocketClient(); WebSocketConnectionManager connectionManager = new

Websockets, SockJs, Stomp, Spring, RabbitMQ, delete User specific Queues automatically

耗尽温柔 提交于 2019-12-04 13:36:23
问题 i hope someone can help me with this issue: I use the Websocket support of Spring. With SockJs and StompJs i subscribe a queue like this: var socket = new SockJS(localhost + 'websocket'); stompClient = Stomp.over(socket); stompClient.connect('', '', function(frame) { stompClient.subscribe("/user/queue/gotMessage", function(message) { gotMessage((JSON.parse(message.body))); }); }, function(error) { }); This works really fine with the SimpMessageSendingOperations of Spring. BUT there is one big

Spring 4 Websocket - Nothing happens

时光怂恿深爱的人放手 提交于 2019-12-04 12:58:40
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/master/complete/src/main/resources/static/sockjs-0.3.4.js"></script> <script src="https://raw

spring-security block websocket (sockjs)

喜你入骨 提交于 2019-12-04 10:57:19
In one of my projects I configured both rest services and websockets, both go through spring security filter that check for JWT. For websockets on the client side, application uses sockjs & stomp (on Angular2) and Spring websockets on the server side (Tomcat 8). When I open connection with Spring security enabled then I get below error two seconds after it gets opened. However when I open connection without spring security enabled connection does not get dropped. angular2 connect()/subscribe()/send() - all go with JWT token public connect() : void { let sockjs = new SockJS('/rest/add?jwt=' +

How to combine Spring Security and js sockjs-client

孤者浪人 提交于 2019-12-04 09:53:12
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/196 ), enforcing this any way it can. Is my evaluation of the dilemma correct, and is there any obvious

Spring Stomp @SendToUser with unauthenticated user not working

我的梦境 提交于 2019-12-04 09:48:51
问题 I'm trying to respond to an unauthenticated user using @SendToUser . Spring 4.1.1 I'm using a newly created Spring Boot application and the only config I have is: @Configuration @EnableWebSocketMessageBroker public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/stomp").withSockJS(); } @Override public void configureMessageBroker(MessageBrokerRegistry registry) {

Push message from Java with Spring 4 WebSocket

扶醉桌前 提交于 2019-12-04 08:56:23
问题 I'd like to push messages from Java to WebSocket clients. I've successfully made a js client send to the server and receive a message back on 2 js clients, so the client side code works fine. My issue is that I'd like to initiate a send when events occur within the Java app. So for example every time 10 orders have been placed send a message to all subscribed clients. Is this possible? My current config: <websocket:message-broker application-destination-prefix="/app"> <websocket:stomp

Spring Boot, Websockets cannot obtain user (i.e, java.security.Principal) from Session

戏子无情 提交于 2019-12-04 08:55:37
Working with Spring Boot 1.2.1.RELEASE and Spring Websockets . Having a deployment runtime issue where when running embedded Jetty 9 , I cannot fake a user ( java.security.Principal ) successfully when app deployed anywhere else but localhost. I have consulted http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-authentication http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-server-runtime-configuration The config below (I believe) already "upgrades" a request @Configuration

Spring 4 AbstractWebSocketMessageBrokerConfigurer With SockJS Not Negotiating Transport Properly

前提是你 提交于 2019-12-04 06:41:12
So I must say that all of the websocket tutorials/examples appear to be so easy, but it seems you really have to dig to find really important pieces of information that are left out of the simple examples. I'm stil having quite a few issues with my webapp using the Spring 4 Stomp message broker with SockJS on the front end. Currently, if I add an endpoint to the StompEndpointRegistry without enabling SockJS(), then declare my socket on the front end using dojo's dojox/socket, Firefox 28 will open a websocket just fine. However, I need support in IE8 and IE9, so I switched to SockJS. Using