刚接触这个,使用spring4+tomcat8,运行后,报错,提示
2015-08-18 21:40:30,194[org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver]-[DEBUG] Resolving exception from handler [org.springframework.web.socket.server.support.WebSocketHttpRequestHandler@59a6cc]: org.springframework.web.socket.server.HandshakeFailureException: Uncaught failure for request http://localhost:8080/spring4/myHandler; nested exception is java.lang.IllegalArgumentException: The extension [x-webkit-deflate-frame] is not supported
2015-08-18 21:40:30,195 [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver]-[DEBUG] Resolving exception from handler [org.springframework.web.socket.server.support.WebSocketHttpRequestHandler@59a6cc]: org.springframework.web.socket.server.HandshakeFailureException: Uncaught failure for request http://localhost:8080/spring4/myHandler; nested exception is java.lang.IllegalArgumentException: The extension [x-webkit-deflate-frame] is not supported这个说明浏览器比较旧(估计是safari,至少safari6就是这样,safari8不知道有无此问题),对于websocket压缩还是用的很老的非规范的扩展“x-webkit-deflate-frame”,新的firefox,chrome都不会发这个扩展头信息,而是发送草案中规范的“permessage-deflate”。但是另外spring4对于这个非规范的老扩展兼容也不太好(其实就是bug),按理应该忽略这个扩展,让tomcat和浏览器进行非压缩的websocket通讯即可。<spanstyle="font-size:13.3333330154419px;">spring4看起来比较矫情,它采取了抛异常,这是不合理的。而tomcat8自带的examples中websocket的例子对于“<spanstyle="font-size:13.3333330154419px;">x-webkit-deflate-frame”不会出问题,因为tomcat8对于<spanstyle="font-size:13.3333330154419px;">x-webkit-deflate-frame是采取忽略的态度,不回发压缩扩展协商成功的头,即表明采用非压缩方式传输,这样就没有问题了。
web.socket
看起来你的浏览器不支持,导致spring的这个扩展也报错了
我试过多个浏览器都还是一样<spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">org.springframework.web.socket.server.HandshakeFailureException:Uncaughtfailureforrequesthttp://localhost:8080/spring4/myHandler;nestedexceptionisjava.lang.IllegalArgumentException:Theextension[x-webkit-deflate-frame]isnotsupported
<spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">
<spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> 注意这个估计是websocket的问题 <spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">spring4/myHandler这个是你自己写的吧问题在这
<divclass='ref'><spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">org.springframework.web.socket.server.HandshakeFailureException:Uncaughtfailureforrequesthttp://localhost:8080/spring4/myHandler;nestedexceptionisjava.lang.IllegalArgumentException:Theextension[x-webkit-deflate-frame]isnotsupported
<spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">
<spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> 注意这个估计是websocket的问题 <spanstyle="font-family:'MicrosoftYaHei',Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">spring4/myHandler这个是你自己写的吧问题在这
<divclass='ref'>版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。