【WebSocket】SpringBoot中,WebSocket客户端连接服务端时,出现SockJsException: Uncaught failure in SockJS...异常信息

5 篇文章 0 订阅
4 篇文章 0 订阅

错误信息:

2019-01-18 10:58:32.094 ERROR 11113 --- [nio-8086-exec-9] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/energymanagement] threw exception [Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://192.168.168.180:8086/xxxxx/socket/690/a4o3vo4b/xhr?t=1547780328164; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to open session; nested exception is java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container] with root cause

java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container

....//省略其他异常信息

at com.xxxxxx.energymanagement.CrossFilter.doFilter(CrossFilter.java:37) ~[classes!/:0.0.1-SNAPSHOT]

.....//省略其他异常信息

错误中,只有这一句是关于项目中文件,而且是一个Fileter

 

错误原因:

具体原因不清楚,可以参考https://www.cnblogs.com/guangshan/p/4916993.html该博主的分享

 

错误解决:

在项目中的所有Filter中的@WebFilter增加异步支持asyncSupported=true

EG:@WebFilter(filterName = "CrossFilter", urlPatterns = "/*",asyncSupported=true)

同时在项目的启动类增加@EnableAsync注解。经测试,此方法可以解决该异常。

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值