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

182
Visualizações
React WebSocket Fails Without Error for Spring Boot

I validated that my websocket works by using Postman, however when I try and use the Javascript WebSocket class to connect from the frontend, I get a WebSocket connection to 'ws://...' failed that does not provide any error or description. I understand that for security reasons the browser does not display a comprehensive error message, however I am unsure what is going on and how to fix it.

Frontend:

ReactDOM.render(<Testing />, document.getElementById('root))

const Testing = () => {
  let socket = new WebSocket("ws://localhost:8080/ws-setup/websocket")
  return <div>Testing Page</div>
}

Postman: Set type to Raw, add 'ws://localhost:8080/ws-setup/websocket' and click connect. It tells me the connection was established in the messages viewport.

Configuration file in Spring Boot:

@Override
public void configureMessageBroker(final MessageBrokerRegistry config)
{
    config.enableSimpleBroker("/branches-ws");
    config.setApplicationDestinationPrefixes("/ws");
}

@Override
public void registerStompEndpoints(final StompEndpointRegistry registry)
{
    registry
            .addEndpoint("/ws-setup")
            .setAllowedOrigins("*")
            .withSockJS();
}

Why is it not working?

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