spring-websocket

how can i make spring websocket + node.js client

[亡魂溺海] 提交于 2021-02-11 14:02:29
问题 how can i create a websocket stomp client (WebSocketStompClient) in node.js like i do in java with this lines.. WebSocketStompClient stompClient = new WebSocketStompClient(new SockJsClient(createTransportClient())); stompClient.setMessageConverter(new MappingJackson2MessageConverter()); StompSession stompSession = stompClient.connect("ws://localhost:8081/stomp", new StompSessionHandlerAdapter() { }).get(10, SECONDS); i´ve tried several websocket projects in node.js, but none of them work 回答1:

How to unit test Spring WebSocketStompClient

时光总嘲笑我的痴心妄想 提交于 2021-02-10 05:20:48
问题 I've a Stompclient which connects to a Spring boot server and performs some subscriptions. The code coverage for this websocket client is at 0%. I can only find the code samples for how to unit test Spring boot Websocket server. But this is client side verifying the Stompclient is working fine. Please let me know if my question is missing any details. Here's my sample connect method which I need to write unit test case for. StompSession connect(String connectionUrl) throws Exception {

How to unit test Spring WebSocketStompClient

巧了我就是萌 提交于 2021-02-10 05:20:40
问题 I've a Stompclient which connects to a Spring boot server and performs some subscriptions. The code coverage for this websocket client is at 0%. I can only find the code samples for how to unit test Spring boot Websocket server. But this is client side verifying the Stompclient is working fine. Please let me know if my question is missing any details. Here's my sample connect method which I need to write unit test case for. StompSession connect(String connectionUrl) throws Exception {

Spring Boot WebSockets unable to find the current user (principal)

拥有回忆 提交于 2021-02-08 09:35:13
问题 After signing-in, the websockets cannot find the current user by session.getPrincipal() (it returns null). Here is the Java code for WebSockets: @Configuration @EnableWebSocketMessageBroker public class WebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/queue", "/topic"); config.setApplicationDestinationPrefixes("/socket"); config.setUserDestinationPrefix("/user"); }

Spring Boot WebSockets unable to find the current user (principal)

孤人 提交于 2021-02-08 09:34:07
问题 After signing-in, the websockets cannot find the current user by session.getPrincipal() (it returns null). Here is the Java code for WebSockets: @Configuration @EnableWebSocketMessageBroker public class WebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/queue", "/topic"); config.setApplicationDestinationPrefixes("/socket"); config.setUserDestinationPrefix("/user"); }

stomp/sockjs 404 not found error in jboss 6.4

穿精又带淫゛_ 提交于 2021-02-08 03:08:25
问题 I m trying to deploy spring-websocket-portfolio sample app wich use stomp/sockjs client with spring j2ee server . the same war package succeed in Tomcat7 and failed in jboss 6.4 and Tomcat6 with 404 error code . The error in chrome console is : sockjs.js:1622 GET http://localhost:8080/spring-websocket-portfolio/portfolio/info?t=1466117690528 404 (Not Found) Any idea ? 回答1: Your server needs to be Servlet 3.0+ and should support the websocket API. You'll find the list of officially supported

Spring boot 2 reactive web websocket conflict with datarest

让人想犯罪 __ 提交于 2021-02-07 20:26:20
问题 I'm using spring boot 2 to create a project and use websocket using reactive web dependency. My application is worked correctly until I add datarest dependency. after I add datarest dependency application give ' failed: Error during WebSocket handshake: Unexpected response code: 404 is any way to resolve this conflict?. pom.xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-integration</artifactId> </dependency> <dependency> <groupId

How to use Spring Reactive WebSocket and transform it into the Flux stream?

点点圈 提交于 2021-02-06 09:27:08
问题 There is some WebSocketClient example on Spring documentation: WebSocketClient client = new ReactorNettyWebSocketClient(); client.execute("ws://localhost:8080/echo"), session -> {...}).blockMillis(5000); Im not sure how to handle stream of incomming data? Inside that block {...} . I mean: how can I filter incoming data and cast it into Flux? Here is what I want to get. @GetMapping("/stream", produces = MediaType.APPLICATION_STREAM_JSON_VALUE) public Flux<MyRecourse> getStreaming() { // get

How to get Authentication from X-Auth-Token?

↘锁芯ラ 提交于 2021-01-29 15:35:32
问题 My goal is to authenticate the WebSocket CONNECT frame. I wish to be able to initialize Authentication user = ... by using X-Auth-Token . TL:DR I use the X-Auth-Token header. How the current authentication works: User hit POST /login endpoint with Form Data username and password . The response header will contain the key X-Auth-Token . If you hit any REST endpoint with X-Auth-Token the server will recognize the user. The issue is how to get Authentication from X-Auth-Token in the WebSocket

Spring 4.2.0 - How to use SimpUserRegistry

人盡茶涼 提交于 2021-01-23 06:33:53
问题 According with the Spring 4.2.0 documentation, item 5.5, I'm trying to use SimpUserRegistry to get the users list connected to an websockets/STOMP endpoint ...but I'm pretty new on Spring and I just don't know where/how to use this class. Can you provide me an example or point me in the right direction? 回答1: Just inject SimpUserRegistry as a dependency. Here's an example on printing the username of all connected users: @Autowired private SimpUserRegistry userRegistry; public void