File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
spring-websocket/src/main/java/org/springframework/web/socket Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -135,11 +135,10 @@ public final class CloseStatus {
135135
136136
137137 /**
138- * Indicates that a session has become unreliable (e.g. timed out while sending
139- * a message) and extra care should be exercised while closing the session in
140- * order to avoid locking additional threads.
141- *
142- * <p><strong>NOTE:</strong> Spring Framework specific status code.
138+ * A status code for use within the framework the indicate a session has
139+ * become unreliable (e.g. timed out while sending a message) and extra
140+ * care should be exercised, e.g. avoid sending any further data to the
141+ * client that may be done during normal shutdown.
143142 */
144143 public static final CloseStatus SESSION_NOT_RELIABLE = new CloseStatus (4500 );
145144
Original file line number Diff line number Diff line change @@ -356,8 +356,13 @@ private String resolveSessionId(Message<?> message) {
356356 }
357357
358358 /**
359- * Periodically check sessions to ensure they have received at least one
360- * message or otherwise close them.
359+ * When a session is connected through a higher-level protocol it has a chance
360+ * to use heartbeat management to shut down sessions that are too slow to send
361+ * or receive messages. However, after a WebSocketSession is established and
362+ * before the higher level protocol is fully connected there is a possibility
363+ * for sessions to hang. This method checks and closes any sessions that have
364+ * been connected for more than 60 seconds without having received a single
365+ * message.
361366 */
362367 private void checkSessions () throws IOException {
363368 long currentTime = System .currentTimeMillis ();
@@ -380,7 +385,7 @@ private void checkSessions() throws IOException {
380385 "Closing " + holder .getSession () + "." );
381386 }
382387 try {
383- session .close (CloseStatus .PROTOCOL_ERROR );
388+ session .close (CloseStatus .SESSION_NOT_RELIABLE );
384389 }
385390 catch (Throwable t ) {
386391 logger .error ("Failure while closing " + session , t );
You can’t perform that action at this time.
0 commit comments