I have been working with spring boot and stomp server for sometime now. After using it for sometime I found that my logs are filled with the following waring messages.
08:58:36.026 [38] [http-nio-8080-exec-8] WARN org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'application/javascript;charset=UTF-8'],
To investigate further what is happening I set spring framework logging to TRACE
and the rest of the log is given below.
08:58:35.991 [94] [clientOutboundChannel-14] TRACE org.springframework.web.socket.sockjs.transport.handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession - 1 message(s) to flush in session d3zz_wqj,
08:58:35.991 [94] [clientOutboundChannel-14] TRACE org.springframework.web.socket.sockjs.transport.handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession - Session is active, ready to flush.,
08:58:35.991 [94] [clientOutboundChannel-14] TRACE org.springframework.web.socket.sockjs.transport.handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession - Preparing to write SockJsFrame content='a[\"\\n\"]',
08:58:35.991 [94] [clientOutboundChannel-14] TRACE org.springframework.web.socket.sockjs.transport.handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession - Writing to HTTP response: a[\"\\n\"],
08:58:35.992 [94] [clientOutboundChannel-14] TRACE org.springframework.web.socket.sockjs.DisconnectedClient - Looks like the client has gone away,
08:58:35.994 [94] [clientOutboundChannel-14] DEBUG org.springframework.web.socket.sockjs.transport.handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession - Closing SockJS session d3zz_wqj with CloseStatus[code=1011, reason=null],
08:58:35.994 [94] [clientOutboundChannel-14] DEBUG org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator - XhrStreamingSockJsSession[id=d3zz_wqj] closed with CloseStatus[code=1011, reason=null],
08:58:35.994 [94] [clientOutboundChannel-14] DEBUG org.springframework.web.socket.messaging.SubProtocolWebSocketHandler - Clearing session d3zz_wqj,
08:58:35.994 [94] [clientOutboundChannel-14] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [102] [clientInboundChannel-21] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [94] [clientOutboundChannel-14] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [100] [clientInboundChannel-19] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [94] [clientOutboundChannel-14] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [103] [clientInboundChannel-22] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'getTracer',
08:58:35.994 [103] [clientInboundChannel-22] DEBUG org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler - Forwarding DISCONNECT session=d3zz_wqj,
08:58:35.994 [103] [clientInboundChannel-22] TRACE org.springframework.messaging.simp.stomp.StompEncoder - Encoding STOMP DISCONNECT, headers=null,
08:58:35.996 [46] [tcp-client-loop-nio-4] DEBUG org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler - Cleaning up connection state for session d3zz_wqj,
08:58:35.996 [46] [tcp-client-loop-nio-4] DEBUG org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler - Closing TCP connection in session d3zz_wqj,
08:58:35.998 [94] [clientOutboundChannel-14] DEBUG org.springframework.web.socket.messaging.StompSubProtocolHandler - Failed to send WebSocket message to client in session d3zz_wqj,
08:58:36.005 [38] [http-nio-8080-exec-8] TRACE org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter - Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@2f4e2263",
08:58:36.005 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.servlet.DispatcherServlet - \"INCLUDE\" dispatch for POST \"/socket/error\", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet',
08:58:36.010 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - 2 matching mappings: [{ [/error]}, { [/error], produces [text/html]}],
08:58:36.010 [38] [http-nio-8080-exec-8] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'basicErrorController',
08:58:36.010 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest),
08:58:36.018 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.method.HandlerMethod - Arguments: [org.apache.catalina.core.ApplicationHttpRequest@2f4e2263],
08:58:36.021 [38] [http-nio-8080-exec-8] DEBUG org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor - Found 'Content-Type:application/javascript;charset=UTF-8' in response,
08:58:36.022 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.method.HandlerMethod - Error handling return value=[<200 OK OK,{timestamp=Fri May 27 08:58:36 UTC 2022, status=200, error=OK, path=/socket/ws/067/d3zz_wqj/xhr_streaming},[]>], type=org.springframework.http.ResponseEntity in org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest),
08:58:36.026 [38] [http-nio-8080-exec-8] WARN org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'application/javascript;charset=UTF-8'],
08:58:36.026 [38] [http-nio-8080-exec-8] TRACE org.springframework.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned.,
08:58:36.027 [38] [http-nio-8080-exec-8] DEBUG org.springframework.web.servlet.DispatcherServlet - Exiting from \"INCLUDE\" dispatch, status 200, headers={masked},
08:58:36.027 [38] [http-nio-8080-exec-8] TRACE org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter - Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest@2f4e2263,
Looking at the logs I can see that before the server could send the frame a["\n"]
to the client, the client has already disconnected and trying to send the frame to closed socket is causing the error. Is there any proper way to handle this error?