Below is config file package rest.api.config;

import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.Message; import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.security.authorization.AuthorizationManager; import org.springframework.security.config.annotation.web.socket.EnableWebSocketSecurity; import org.springframework.security.messaging.access.intercept.MessageMatcherDelegatingAuthorizationManager; import org.springframework.security.web.firewall.DefaultHttpFirewall; import org.springframework.security.web.firewall.HttpFirewall; import org.springframework.util.MimeTypeUtils; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; import rest.api.service.WebSocketService;

import java.util.List;

/* * Configuration class to configure Spring for STOMP messaging * * @author M. Abdullah Onus on 11/14/2017 / @Configuration @EnableWebSocketMessageBroker @EnableWebSocketSecurity public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

private static final Logger logger = LogManager.getLogger(WebSocketConfig.class);

@Autowired private ObjectMapper objectMapper;

/* * Web socket message broker configuration. Messages are published directly to users, not to a topic. So we only * enable "/user" destination. Each user has his own "inbox" that is configured in {@link * rest.api.controller.WebSocketController}. Subscription can be done through "/user/{userId}/inbox" for a specific * user. * * @param config / @Override public void configureMessageBroker(MessageBrokerRegistry config) { logger.error("configureMessageBroker"); config.enableSimpleBroker("/user", "/work"); config.setApplicationDestinationPrefixes("/user", "/work"); config.setUserDestinationPrefix("/user"); }

@Bean AuthorizationManager<Message<?>> authorizationManager(MessageMatcherDelegatingAuthorizationManager.Builder messages) { logger.error("authorizationManager"); messages.nullDestMatcher().authenticated().simpTypeMatchers(SimpMessageType.SUBSCRIBE) .authenticated().anyMessage() .denyAll(); return messages.build(); }

/ * Register stomp endpoints enabling SockJS fallback options. Connection can be established between client and server * through "{serverUrl}/{contextName}/psapi/{registeredEndpoint}". eg. http://localhost:8080/qaauto01/psapi/socket * * @param registry / @Override public void registerStompEndpoints(StompEndpointRegistry registry) { logger.error("registerStompEndpoints"); registry.addEndpoint("/socket").setAllowedOrigins("").withSockJS(); }

@Override public boolean configureMessageConverters(List messageConverters) { logger.error("configureMessageConverters"); DefaultContentTypeResolver resolver = new DefaultContentTypeResolver(); resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON); MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); converter.setObjectMapper(objectMapper); converter.setContentTypeResolver(resolver); messageConverters.add(converter); return false; } }

Below is conroller

package rest.api.controller;

import com.cinteractive.ps3.entities.User; import com.cinteractive.ps3.work.Work; import java.security.Principal; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.DestinationVariable; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; import org.springframework.stereotype.Controller; import rest.api.dto.MessageCountDTO; import rest.api.dto.WorkDTO; import rest.api.dto.support.metricBulkActions.MetricBulkActionsRunProgress; import rest.api.dto.support.metricBulkActions.MetricBulkActionsRunResult; import rest.api.mapper.WorkMapper; import rest.api.service.UserService; import rest.api.service.WorkService; import rest.api.service.support.MessageSupport;

/* * Web socket controller to initialize subscription after a page refresh / @Controller public class WebSocketController extends BaseController {

private final UserService userService; private final WorkService workService;

@Autowired WebSocketController(UserService userService, WorkService workService) { this.userService = userService; this.workService = workService; }

/* * Send message count to user after subscription * * @param userId the ID of the owner of topic * @param principal the authenticated {@link Principal} * @return message count / @SubscribeMapping("/{userId}/inbox/message-count") public MessageCountDTO messageCount(Principal principal, @DestinationVariable("userId") String userId) { PreAuthenticatedAuthenticationToken token = (PreAuthenticatedAuthenticationToken) principal; User user = (User) token.getPrincipal(); return MessageSupport .messageCount(user.getId().toString().equals(userId) ? user : userService.findById(user.getContext(), userId)); }

@SubscribeMapping("/{workId}/lock-status") public WorkDTO workLock(Principal principal, @DestinationVariable("workId") String workId) { PreAuthenticatedAuthenticationToken token = (PreAuthenticatedAuthenticationToken) principal; User user = (User) token.getPrincipal(); Work work = workService.findById(user.getContext(), workId); return new WorkMapper(user).toDTO(work, WorkMapper.SUMMARY_FIELDS); }

@SubscribeMapping("/{userId}/bulk-metric-actions") public MetricBulkActionsRunProgress metricBulkActionsProgress(Principal principal, @DestinationVariable("userId") String userId) { return null; } }

Error on front end rxjs-websocket.service.ts:25 WebSocket connection to 'wss://localhost:8443/pristine_100_885083_java17/psapi/socket/websocket' failed:

Before spring 5.3 it is working

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.