File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
spring-websocket/src/main/java/org/springframework/web/socket Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ public interface WebSocketSession extends Closeable {
120120
121121 /**
122122 * Send a WebSocket message: either {@link TextMessage} or {@link BinaryMessage}.
123+ *
124+ * <p><strong>Note:</strong> The underlying standard WebSocket session (JSR-356) does
125+ * not allow concurrent sending. Therefore sending must be synchronized. To ensure
126+ * that, one option is to wrap the {@code WebSocketSession} with the
127+ * {@link org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator
128+ * ConcurrentWebSocketSessionDecorator}.
129+ * @see org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator
123130 */
124131 void sendMessage (WebSocketMessage <?> message ) throws IOException ;
125132
Original file line number Diff line number Diff line change @@ -102,12 +102,18 @@ The following example shows the XML configuration equivalent of the preceding ex
102102----
103103====
104104
105- The pereceding example is for use in Spring MVC applications and should be included in the
105+ The preceding example is for use in Spring MVC applications and should be included in the
106106configuration of a <<mvc-servlet,`DispatcherServlet`>>. However, Spring's WebSocket
107107support does not depend on Spring MVC. It is relatively simple to integrate a `WebSocketHandler`
108108into other HTTP-serving environments with the help of
109109{api-spring-framework}/web/socket/server/support/WebSocketHttpRequestHandler.html[`WebSocketHttpRequestHandler`].
110110
111+ When using the `WebSocketHandler` API directly vs indirectly, e.g. through the
112+ <<websocket-stomp>> messaging, the application must synchronize the sending of messages
113+ since the underlying standard WebSocket session (JSR-356) does not allow concurrent
114+ sending. One option is to wrap the `WebSocketSession` with
115+ {api-spring-framework}/web/socket/handler/ConcurrentWebSocketSessionDecorator.html[`ConcurrentWebSocketSessionDecorator`].
116+
111117
112118
113119[[websocket-server-handshake]]
You can’t perform that action at this time.
0 commit comments