Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
Obteniendo múltiples errores 401 en la consola cuando se conecta a websocket usando sockjs en la aplicación Spring Boot

Tenemos un microservicio websocket ejecutándose en un servidor de desarrollo detrás de la puerta de enlace. Aquí está la pieza de código que estoy usando para conectarme usando sockjs.

 function connect() { var socket = new SockJS('https://dev.my.net/api/v1/websocket/app'); stompClient = Stomp.over(socket); stompClient.connect({}, function(frame) { setConnected(true); console.log('Connected: ' + frame); stompClient.subscribe('/topic', function(messageOutput) { showMessageOutput(JSON.parse(messageOutput.body)); }); });

Aquí está la configuración de arranque de primavera para websocket:

 @Configuration @EnableWebSocketMessageBroker public class WebsocketConfig implements WebSocketMessageBrokerConfigurer { final WebSocketHandshakeAuthInterceptor webSocketHandshakeAuthInterceptor; @Autowired public WebsocketConfig(WebSocketHandshakeAuthInterceptor webSocketHandshakeAuthInterceptor) { this.webSocketHandshakeAuthInterceptor = webSocketHandshakeAuthInterceptor; } @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/app") .addInterceptors(webSocketHandshakeAuthInterceptor) .setAllowedOriginPatterns("*"); registry.addEndpoint("/app") .addInterceptors(webSocketHandshakeAuthInterceptor) .setAllowedOriginPatterns("*").withSockJS() .setSupressCors(true); } @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/topic"); }

}

El error que estoy recibiendo en la consola:

 WebSocket connection to 'wss://dev.my.net/api/v1/websocket/app/646/x5eauxus/websocket?Authorisation=Bearer asdfghjkl' failed: https://dev.my.net/api/v1/websocket/app/646/vmlurtte/xhr_streaming?Authorisation=Bearer asdfghjkl 401 https://dev.my.net/api/v1/websocket/app/646/uhfyhy05/eventsource?Authorisation=Bearer asdfghjkl 401 chromewebdata/:1 Failed to load resource: the server responded with a status of 401 () chromewebdata/:1 Failed to load resource: the server responded with a status of 401 () chromewebdata/:1 Refused to display 'https://dev.my.net/' in a frame because it set 'X-Frame-Options' to 'deny'. chromewebdata/:1 Refused to display 'https://dev.my.net/' in a frame because it set 'X-Frame-Options' to 'deny'.

¿Alguien puede decirme por qué recibo errores 401? Sé que está tratando de usar todas las opciones alternativas posibles para conectarse usando sockjs.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda