title: Spring Boot - SimpMessagingTemplate is not sending messages to the client in spring boot websocket with spring boot security
body: <p>No matter whatever I do I am not able to send data to the HTML client from controller by using spring boot websocket. I almost tried everything but nothing worked for me. Below is my code.</p>
  <p><strong>This is my AdminTournamentController.class</strong></p>
  <pre><code>@Controller
  @Transactional
  public class AdminTournamentController {
  
  @Autowired
  private AdminTournamentService adminTournamentService;
  
  @Autowired
  private LabelComponent labelComponent;
  
  @Autowired
  private SimpMessagingTemplate template;
  
  @RequestMapping(&quot;/admin/AddTournament&quot;)
  public String addTournament(Model model) {
      model.addAttribute(&quot;labelComponent&quot;, labelComponent);
      model.addAttribute(&quot;adminTournamentModel&quot;, new AdminTournamentModel());
      return &quot;/admin/AddTournament&quot;;
  }
  
  @RequestMapping(&quot;/admin/SaveTournament&quot;)
  @Transactional
  public String saveTournament(@ModelAttribute @Valid AdminTournamentModel adminTournamentModel,
          HttpServletRequest request, BindingResult bindingResult, Model model) {
      model.addAttribute(&quot;labelComponent&quot;, labelComponent);
      try {
          // Here is the convert and send method
          template.convertAndSend(&quot;topic/user/Tournaments&quot;, adminTournamentModel);
          if (bindingResult.hasErrors()) {
              return &quot;/admin/AddTournament&quot;;
          }
          if (adminTournamentModel.getTournamentName().trim().isEmpty()) {
              bindingResult.rejectValue(&quot;tournamentName&quot;, &quot;error&quot;, &quot;Tournament name cannot be empty&quot;);
              return &quot;/admin/AddTournament&quot;;
          }
  </code></pre>
  <p><strong>This is my MessageHandlingController.class</strong></p>
  <pre><code>@Controller
  public class MessageHandlingController {
  
  @MessageMapping(&quot;/admin/SaveTournament&quot;)
  @SendTo(&quot;topic/user/Tournaments&quot;)
  public AdminTournamentModel newTouramenst(@Payload AdminTournamentModel adminTournamentModel) {
      System.err.println(&quot;Over here&quot;);
      return adminTournamentModel;
  }
  
  }
  </code></pre>
  <p><strong>This is my SecurityConfiguration.class</strong></p>
  <pre><code>@Override
  protected void configure(HttpSecurity httpSecurity) throws Exception {
      httpSecurity.csrf().disable().authorizeRequests()
              .antMatchers(&quot;/admin/**&quot;).hasAuthority(&quot;ADMIN&quot;)
              .antMatchers(&quot;/user/**&quot;).hasAuthority(&quot;USER&quot;)
              .antMatchers(&quot;/**&quot;).permitAll()
              .anyRequest().authenticated().and()
              .formLogin().loginPage(&quot;/login&quot;).loginProcessingUrl(&quot;/validateLogin&quot;).failureUrl(&quot;/login?error&quot;) 
              .defaultSuccessUrl(&quot;/successLogin&quot;, true)
              .and().rememberMe().rememberMeParameter(&quot;rememberMe&quot;).rememberMeCookieName(&quot;exidious&quot;).tokenValiditySeconds(604800)
              .and().sessionManagement().maximumSessions(1)
              .maxSessionsPreventsLogin(true)
              .and().sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
              .and().logout().logoutUrl(&quot;/user/logout&quot;).logoutSuccessUrl(&quot;/login?logout&quot;).deleteCookies(&quot;exidious&quot;)
              .invalidateHttpSession(true);
  }
  </code></pre>
  <p><strong>This is my WebSocketConfiguration.class</strong></p>
  <pre><code>@Configuration
  @EnableWebSocketMessageBroker
  public class WebSocketConfiguration implements WebSocketMessageBrokerConfigurer {
  
  @Override
  public void configureMessageBroker(MessageBrokerRegistry registry) {
      registry.enableSimpleBroker(&quot;/topic&quot;);
      registry.setApplicationDestinationPrefixes(&quot;/app&quot;);
  }
  
  @Override
  public void registerStompEndpoints(StompEndpointRegistry registry) {
      registry.addEndpoint(&quot;/exidious&quot;).withSockJS();
  }
  </code></pre>
  <p><strong>Here is the client side:- Client side is html file</strong></p>
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html lang=&quot;en&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
  &lt;title th:text='${labelComponent.getLabel(&quot;AAA045&quot;)}'&gt;&lt;/title&gt;
  &lt;meta charset=&quot;utf-8&quot; /&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;
  &lt;link rel=&quot;stylesheet&quot;
      href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css&quot;&gt;
  &lt;script
      src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script
      src=&quot;https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js&quot;&gt;&lt;/script&gt;
  &lt;script
      src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
  &lt;link href=&quot;/webjars/bootstrap/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;script src=&quot;/webjars/jquery/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;/webjars/sockjs-client/sockjs.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;/webjars/stomp-websocket/stomp.min.js&quot;&gt;&lt;/script&gt;
  &lt;link rel=&quot;stylesheet&quot; th:href=&quot;@{../css/exidious.css}&quot;&gt;
  &lt;/head&gt;
  &lt;body onload=&quot;connect();&quot;&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  function connect() {
      var socket = new SockJS('/exidious');
      stompClient = Stomp.over(socket);
      stompClient.connect({}, function (frame) {
          console.log('Connected: ' + frame);
          stompClient.subscribe('/topic/user/Tournaments', function (tournaments) {
              alert(1);
              tournamentsFunction(tournaments);
          });
      });
      
      function tournamentsFunction(tournaments) {
          $(&quot;#greetings&quot;).append(&quot;&lt;tr&gt;&lt;td&gt;&quot; + JSON.parse(tournaments.body) + &quot;&lt;/td&gt;&lt;/tr&gt;&quot;);
      }
  }
  &lt;/script&gt;
      &lt;div th:replace=&quot;fragments/userHeader&quot; &gt;&amp;nbsp;&lt;/div&gt;
      &lt;div class=&quot;content&quot;&gt;
           &lt;table id=&quot;conversation&quot; class=&quot;table table-striped&quot;&gt;
                  &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Greetings&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody id=&quot;greetings&quot;&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>