Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
WebSockets no se conecta debido a la pérdida de conexión

Estoy usando spring boot en mi backend y vuejs en mi front-end. He definido todo en la guía pero todavía no logro que mi proyecto funcione.

Interfaz

 connectToWS() { this.socket = new Sock("http://localhost:8754/stomp-endpoint"); this.stompClient = Stomp.over(this.socket); this.stompClient.connect( {}, frame => { this.connected = true; console.log(frame); this.stompClient.subscribe("/topic/greetings", tick => { console.log(tick); this.received_messages.push(JSON.parse(tick.body).content); }); }, error => { console.log(error); this.connected = false; } ); },

back-end

Clase de configuración de WebSocket:

 @Configuration @EnableWebSocketMessageBroker public class WebsocketConfiguration implements WebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { // with sockjs registry.addEndpoint("/stomp-endpoint") .setAllowedOrigins("http://localhost:8081") .withSockJS(); } @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.setApplicationDestinationPrefixes("/app") .enableSimpleBroker("/topic"); } }

WebSecurityConfigClass:

 @Override protected void configure(HttpSecurity http) throws Exception { http.cors().and().csrf().disable() .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .authorizeRequests() .antMatchers("/api/v*/registration/**").permitAll() .antMatchers("/topic**").permitAll() .antMatchers("/stomp-endpoint").permitAll()

Error de WebSocket en el navegador La URL cambió a /stomp-endpoint/info....

ACTUALIZACIÓN: El error en realidad proviene del navegador. En realidad, cambia la ruta de la API porque tiene sockjs integrado. No pude entender por qué la API siempre obtiene un /info?t=RandomNumber después. Necesito que la ruta siga siendo la misma que escribí en el front-end. ¿Cómo puedo evitar que el navegador actualice mi ruta? Gracias por ayudar !

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!