У меня следующая конфигурация WebSocket:
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/game");
registry.addEndpoint("/game").withSockJS();
}
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(subscriptionInterceptor());
}
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
}
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/all","/user", "/table");
config.setApplicationDestinationPrefixes("/app");
config.setPreservePublishOrder(true);
}
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registry) {
registry.setMessageSizeLimit(5 * 1024 * 1024);
registry.setSendBufferSizeLimit(5 * 1024 * 1024);
registry.setSendTimeLimit(60 * 1000);
}
@Bean
public SubscriptionInterceptor subscriptionInterceptor() {
return new SubscriptionInterceptor();
}
}
У меня около 30 JS клиентов, подключенных к моему серверу с помощью Sock JS для отправки сообщений. Время от времени я получаю следующую ошибку:
ERROR 14607 --- [io-8080-exec-17] .w.s.a.s.StandardWebSocketHandlerAdapter : Closing session due to exception for StandardWebSocketSession[id=11d93b6a-7de1-354b-4f33-5834a89da351, uri=ws://41.250.241.235:8080/game/352/qbd0x4z4/websocket]
org.springframework.web.socket.sockjs.SockJsMessageDeliveryException: Failed to deliver message(s) [SEND
destination:/app/table/7/request/newFrame
content-length:2
{}] for session qbd0x4z4; nested exception is org.springframework.web.socket.sockjs.SockJsMessageDeliveryException: Failed to deliver message(s) [SEND
destination:/app/table/7/request/newFrame
content-length:2
{}] for session qbd0x4z4: Session closed
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateMessages(AbstractSockJsSession.java:391) ~[spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.handleMessage(WebSocketServerSockJsSession.java:195) ~[spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler.handleTextMessage(SockJsWebSocketHandler.java:93) ~[spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43) ~[spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:114) [spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:43) [spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:85) [spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:82) [spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:395) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsFrameServer.sendMessageText(WsFrameServer.java:119) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:495) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:294) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:133) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:82) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148) [tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54) [tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:59) [tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) [tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.31.jar:9.0.31]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.31.jar:9.0.31]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: org.springframework.web.socket.sockjs.SockJsMessageDeliveryException: Failed to deliver message(s) [SEND
destination:/app/table/7/request/newFrame
content-length:2
{}] for session qbd0x4z4: Session closed
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateMessages(AbstractSockJsSession.java:383) ~[spring-websocket-5.1.14.RELEASE.jar:5.1.14.RELEASE]
... 25 common frames omitted
Я понятия не имею, почему я получаю такую ошибку. Я искал все в inte rnet, но я не нашел решения этой проблемы, или, по крайней мере, кто-то, кто может объяснить, что происходит.
Благодарен, если опытный программист с Spring и Websocket может помочь.