[英]Spring boot with Stomp gives HttpMessageNotWritableException
I have been using spring boot with stomp server for websocket with sockjs as frontend library.我一直在使用带有 stomp 服务器的 spring boot 和 sockjs 作为前端库的 websocket。 Intermittently I get the following message in the logs.我在日志中间歇性地收到以下消息。
11:10:15.017 [37] [http-nio-8080-exec-7] 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']
As far as I have read this occurs when wrong content type is recieved in controller.据我所知,当控制器收到错误的内容类型时会发生这种情况。 But this data comes in through websocket and all the data is made to string using JSON.Stringify
from frontend and recieved by @MessageMapping
annoted controller.但是这些数据是通过 websocket 进入的,所有数据都是使用来自前端的JSON.Stringify
进行字符串处理,并由@MessageMapping
注释控制器接收。 Iam not able to understand why this error occurs , could there be other reasons for this issue to occur.我无法理解为什么会发生此错误,是否还有其他原因导致此问题发生。 I have used ActiveMQ as the message broker.我使用 ActiveMQ 作为消息代理。
Can someone throw some light into what could be happening here.有人可以对这里可能发生的事情有所了解。
I figured out the issue myself.我自己弄清楚了这个问题。 Issue occurs when the stomp server try to send heart beat from server to client.当 stomp 服务器尝试将心跳从服务器发送到客户端时,会出现问题。 If the client disconnects while the server is sending the heartbeat, the issue occurs.如果客户端在服务器发送心跳时断开连接,则会出现此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.