diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java index 6886885f23c..56e618d4a1f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -366,10 +366,10 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE logger.debug("Failed to send message to MessageChannel in session " + session.getId(), ex); } else if (logger.isErrorEnabled()) { - // Skip unsent CONNECT messages (likely auth issues) - if (!isConnect || sent) { - logger.error("Failed to send message to MessageChannel in session " + session.getId() + - ":" + ex.getMessage()); + // Skip for unsent CONNECT or SUBSCRIBE (likely authentication/authorization issues) + if (sent || !(isConnect || StompCommand.SUBSCRIBE.equals(command))) { + logger.error("Failed to send message to MessageChannel in session " + + session.getId() + ":" + ex.getMessage()); } } handleError(session, ex, message);