blade集成WebSocket的问题

Blade 未结 1 2391
呆人
呆人 剑童 2019-08-17 23:02

1、资源引入:

    org.springframework.boot

    spring-boot-starter-websocket


2、代码调用:

public class Application extends SpringBootServletInitializer implements WebSocketConfigurer {


   public static void main(String[] args) {

      BladeApplication.run(CommonConstant.APPLICATION_NAME, Application.class, args);

   }


   @Override

   public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {

      registry.addHandler(jobWebSocketHandler(), "/tasks").withSockJS();

   }


   @Bean

   public WebSocketHandler jobWebSocketHandler() {

      return new PerConnectionWebSocketHandler(JobWebSocketHandler.class);

   }


3、运行后遇到的问题:

2019-08-17 22:55:39.194 ERROR 176 --- [p-nio-80-exec-7] w.s.h.ExceptionWebSocketHandlerDecorator : Closing session due to exception for WebSocketServerSockJsSession[id=_0k7lie6]

java.lang.IllegalStateException: WebSocketHandler not found for WebSocketServerSockJsSession[id=_0k7lie6]


at org.springframework.web.socket.handler.PerConnectionWebSocketHandler.getHandler(PerConnectionWebSocketHandler.java:113)


at org.springframework.web.socket.handler.PerConnectionWebSocketHandler.handleTransportError(PerConnectionWebSocketHandler.java:91)


at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleTransportError(WebSocketHandlerDecorator.java:80)


at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleTransportError(LoggingWebSocketHandlerDecorator.java:64)


at org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.handleTransportError(ExceptionWebSocketHandlerDecorator.java:68)


at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateError(AbstractSockJsSession.java:440)


at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.tryCloseWithSockJsTransportError(AbstractSockJsSession.java:425)


at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:127)


at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:312)


at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:438)


at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:133)


at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:53)


at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)


at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)


at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)


at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)


at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)


at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)


at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)


at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)


at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)


at com.github.xiaoymin.swaggerbootstrapui.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:84)


at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)


at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)


at com.github.xiaoymin.swaggerbootstrapui.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)


at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)


at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)


at org.springblade.core.tool.support.xss.XssFilter.doFilter(XssFilter.java:46)


at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)


at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)


at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)


at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)


at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)


at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)


at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)


at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)



1条回答
  • 2021-05-18 10:57

    请问解决了吗?

    1 讨论(0)
提交回复