sockjs

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

Websocket java client Spring + Stomp: Transport error: ConnectionLostException

给你一囗甜甜゛ 提交于 2019-12-22 10:11:09
问题 I'm trying to create an standalone Java app as a websocket client using for this Spring with Stomp and Sockjs, taking in consideration the spring specifications and the spring-portafolio examples and I'm getting this error: 15:18:01.342 [main] DEBUG com.example.client.WebSocketClientTest - Connecting to : ws://localhost:8080/socket/hello 15:18:01.541 [WebSocketClient-AsyncIO-1] ERROR com.example.client.MyStompSessionHandler - Transport error org.springframework.messaging.simp.stomp

SockJsException when websocket client connect to server

梦想的初衷 提交于 2019-12-22 08:05:59
问题 I used spring 4.0.3 with websocket support, my spring config of websocket is: <websocket:message-broker application-destination-prefix="/kiford"> <websocket:stomp-endpoint path="/websocket"> <websocket:sockjs/> </websocket:stomp-endpoint> <websocket:simple-broker prefix="/queue, /topic"/> </websocket:message-broker> When my client connected to the server: this.socket = new SockJS('websocket/'); this.client = Stomp.over(this.socket); this.client.connect({}, success_callback, error_callback);

ReactJS could not proxy request from localhost:3000 to localhost:3003

可紊 提交于 2019-12-22 04:43:11
问题 I am writing a SPA using create-react-app and am using an expressjs server as my backend. For development I run my frontend test server on port 3000 and my backend expressjs test server on 3003. I make many API calls client side using Axios so for development convenience I have defined proxy: "http://localhost:3003" in my package.json This works fine on my laptop, but when running on my workstation I constantly get the error when accessing my app: Proxy error: Could not proxy request /sockjs

ReactJS could not proxy request from localhost:3000 to localhost:3003

*爱你&永不变心* 提交于 2019-12-22 04:43:01
问题 I am writing a SPA using create-react-app and am using an expressjs server as my backend. For development I run my frontend test server on port 3000 and my backend expressjs test server on 3003. I make many API calls client side using Axios so for development convenience I have defined proxy: "http://localhost:3003" in my package.json This works fine on my laptop, but when running on my workstation I constantly get the error when accessing my app: Proxy error: Could not proxy request /sockjs

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

Sending message to client periodically via Spring Web-Socket

拟墨画扇 提交于 2019-12-20 10:43:20
问题 I'm trying to make a connection between client and server via Spring webSocket and I'm doing this by the help of this link. I want Controller to send a "hello" to client every 5 seconds and client append it to the greeting box every time. This is the controller class: @EnableScheduling @Controller public class GreetingController { @Scheduled(fixedRate = 5000) @MessageMapping("/hello") @SendTo("/topic/greetings") public Greeting greeting() throws Exception { Thread.sleep(1000); // simulated

SockJs - 'info' path not found

北城以北 提交于 2019-12-19 10:25:07
问题 I'm running an example of SockJS. Ran npm install (everything okay) Start server with no problem. When I first load the test page, I see that there was a failed 404 call to http://127.0.0.1/echo/info I'm looking at sockjs code and I'm guessing it is called from here - https://github.com/sockjs/sockjs-node/blob/master/src/sockjs.coffee#L81 What is the purpose of this info call and why is it not found? What am I missing in my configuration? 回答1: Your server is listening on 9999 port! So you

Websocket working on localhost but not Heroku

♀尐吖头ヾ 提交于 2019-12-19 03:08:11
问题 I have an application that uses websockets (STOMP over SockJs), with Spring at the backend. Application works fine (websockets) on localhost on Tomcat but when I deploy to Heroku or AWS Web Sockets stop working. My websocket configuration in Angular2 let sockjs = new SockJS('/rest/add?jwt=' + this.authService.getToken(), {"devel":true,"debug":true}, {"transports":["websocket"]}); I also tried with {"disabled_transports":["websocket"]} but both are failing. web.xml <web-app xmlns="http://xmlns

Websocket working on localhost but not Heroku

无人久伴 提交于 2019-12-19 03:07:07
问题 I have an application that uses websockets (STOMP over SockJs), with Spring at the backend. Application works fine (websockets) on localhost on Tomcat but when I deploy to Heroku or AWS Web Sockets stop working. My websocket configuration in Angular2 let sockjs = new SockJS('/rest/add?jwt=' + this.authService.getToken(), {"devel":true,"debug":true}, {"transports":["websocket"]}); I also tried with {"disabled_transports":["websocket"]} but both are failing. web.xml <web-app xmlns="http://xmlns