Hi All
We are frequently finding this exception in our logs:
org.springframework.web.socket.sockjs.SockJsMessageDeliveryException:
Failed to deliver message(s) [] for session nl2a0rcr; nested exception is org.springframework.web.socket.sockjs.SockJsMessageDeliveryException:
Failed to deliver message(s) [] for session nl2a0rcr: Session closed at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateMessages(AbstractSockJsSession.java:391)
Basically it seems that AbstractSockJsSession is trying to deliver an empty message but it raises a SockJsMessageDeliveryException because the session is already closed.
public void delegateMessages(String... messages) throws SockJsMessageDeliveryException {
List<String> undelivered = new ArrayList<>(Arrays.asList(messages));
for (String message : messages) {
try {
if (isClosed()) {
throw new SockJsMessageDeliveryException(this.id, undelivered, "Session closed");
}
else {
this.handler.handleMessage(this, new TextMessage(message));
undelivered.remove(0);
}
Ignoring the fact that it's trying to deliver an empty message, should it avoid throwing an exception when effectively there is nothing to be delivered? If not, how would one handle such exception?
Thanks!
Comment From: raphael-shin
Any Update? I found the same error on my application server too. Like this
org.springframework.web.socket.sockjs.SockJsMessageDeliveryException: Failed to deliver message(s) [
] for session fqp0set2: Session closed
Comment From: rstoyanchev
It shouldn't raise errors for empty messages any more. For any others, it's important to raise an exception because these messages are essentially dropped.