spring-websocket

STOMP or XMPP - Over websocket

大憨熊 提交于 2019-12-12 08:21:30
问题 I am working on a project which involves real time chat (messaging, including group chats). I have worked with websockets before, So I started working on this using spring-websockets and I did some reading about what is the best way to implement it. Then I came across STOMP (as a sub-protocol for websockets)and as there is direct support for STOMP in spring it was bit easy to achieve what I was supposed to do. But my doubt is as far as my understanding STOMP and XMPP are similar protocols

Disallow broadcast in convertAndSendToUser method in SimpMessagingTemplate

女生的网名这么多〃 提交于 2019-12-12 08:01:29
问题 I am working with Spring websocket implementation. For sending a message to clients, there are two ways: 1) Using @SendToUser annotation 2) Using convertAndSendToUser method of SimpMessagingTemplate @SendToUser takes a boolean parameter called broadcast which if set to false publishes the message to the current session. Is there a way I can have this behaviour in SimpMessagingTemplate . 回答1: If we take a look to the SendToMethodReturnValueHandler source code, we'll see: if (broadcast) { this

WebSocket Connection Established, but Client Can't Receive Messages from Others

萝らか妹 提交于 2019-12-12 06:05:48
问题 I use Java Spring 4 and the tutorial I followed is Using websockets in Java using Spring 4 My pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> ... <properties> <java-version>1.8</java-version> <org.springframework-version>4.2.0.RELEASE</org.springframework-version> <org.aspectj-version>1.6.10</org.aspectj-version> <org.slf4j-version

What Uri path to use to connect to Spring WebSocket

穿精又带淫゛_ 提交于 2019-12-12 04:39:48
问题 I have a WebSocket Application using Spring MVC that I have defined as per this tutorial. The file that configures the WebSocket is the following: package com.myapp.spring.web.controller; import java.io.IOException; import javax.websocket.OnClose; import javax.websocket.OnError; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; import org.springframework.web.socket.server.standard.SpringConfigurator;

In spring using websockets getting this error,uncaught type error: onrecieve is not a function(..) stomp.js

爱⌒轻易说出口 提交于 2019-12-12 04:34:30
问题 I am getting this error: uncaught type error: onrecieve is not a function(..) stomp.js Can anyone help me and provide me complete setting using stockjs, stomp and jars? My file:home.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ 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> <head> <title>Reload..</title> <%--

Spring boot application with websocket client only

心不动则不痛 提交于 2019-12-12 04:21:07
问题 I am writing a Spring Boot app that uses spring websocket client with jetty, but I do not need any server functions. How can I switch off Jetty server part, so it won't get activated at startup and does not listen on a port? 回答1: I'm sorry for the delay in having your question answered. I also had difficulty finding the answer, so I created a repository in Github with a simple solution, its here: https://github.com/GleidsonSilva/springboot-ws-client I hope it is still useful to someone! :)

WebSocket, authentication in Spring Boot

久未见 提交于 2019-12-12 01:27:01
问题 I want make some chat, it already works, but i can't get context from SecurityContextHolder, it's always null. Annotations @PreAuthorize and @Secured don't work too, becouse of nulable SecurityContext. How i can get this context or principal? In ordinary controllers it works, but not with the websocket. I want add to message information about user, maybe there is another way? My configuration: @Configuration @EnableWebSocketMessageBroker @ComponentScan(basePackages = "com.antilamer.controller

Error opening websocket connection using spring 4

自古美人都是妖i 提交于 2019-12-11 20:10:09
问题 I am trying to create a websocket using this tutorial . Everything is good except that when I try to open websocket connection I get the following error on my browser console and nothing happens at all. Please help me out. Error: Opening web socket... GET http://localhost:8080/hello/info?t=1445510124841 404 (Not Found) Whoops! Lost connection to http://localhost:8080/hello TestController.java package com.test.controller; import java.util.Set; import javax.servlet.http.HttpServletRequest;

Problem with broker template in spring-websocket

我是研究僧i 提交于 2019-12-11 19:03:43
问题 I am using spring-WebSocket for receiving records via WebSocket channel. After receiving them I send it to an external broker like activeMQ. My configuration looks something like: @Configuration @EnableWebSocketMessageBroker public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/topic"); registry .enableStompBrokerRelay("/topic","/queue") .setRelayHost("127.0.0.1")

Error handling while using STOMP simple broker

孤街醉人 提交于 2019-12-11 18:33:28
问题 I am creating simple STOMP broker using @EnableWebSocketMessageBroker . When RuntimeException happens in @MessageMapping method I would like to receive STOMP ERROR frame, but it doesn't work like that by default. It seems that ERROR frame is not supported in simple broker: https://github.com/spring-projects/spring-framework/blob/master/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java#L28-L44 On the other hand, there is a mechanism to send ERROR frames