WebSocket连接已关闭时无法写入完整的消息

时间:2016-03-26 11:45:49

标签: spring-boot vaadin vaadin-push

我们使用@Push启用了Vaadin Push(transport = Transport.WEBSOCKET_XHR)。 当UI分离时,我们会在日志中看到以下异常。

似乎它不会影响日志中的错误以外的任何内容。你知道如何很好地关闭连接所以我们不填写那些错误的日志吗?

提前谢谢。

07:33:40.853 [http-nio-8080-exec-7] ERROR o.a.container.JSR356Endpoint/log
java.io.IOException: Unable to write the complete message as the WebSocket connection has been closed
        at org.apache.tomcat.websocket.WsSession.registerFuture(WsSession.java:664)
        at org.apache.tomcat.websocket.FutureToSendHandler.get(FutureToSendHandler.java:92)
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessageBlock(WsRemoteEndpointImplBase.java:277)
        at org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:586)
        at org.apache.tomcat.websocket.WsSession.doClose(WsSession.java:488)
        at org.apache.tomcat.websocket.WsSession.close(WsSession.java:455)
        at org.apache.tomcat.websocket.WsSession.close(WsSession.java:449)
        at org.atmosphere.container.version.JSR356WebSocket.close(JSR356WebSocket.java:142)
        at org.atmosphere.cpr.AtmosphereResourceImpl.close(AtmosphereResourceImpl.java:860)
        at com.vaadin.server.communication.ArePushConnection.disconnect(AtmospherePushConnection.java:312)
        at com.basf.gb.cube.seq.vaadinui.MyVaadinUI.detach(MyVaadinUI.java:111)
        at com.vaadin.ui.UI.setSession(UI.java:465)
        at com.vaadin.server.VaadinSession.removeUI(VaadinSession.java:870)
        at com.vaadin.server.VaadinService$1$1.run(VaadinService.java:481)
        at com.vaadin.ui.UI.accessSynchronously(UI.java:1381)
        at com.vaadin.server.VaadinService$1.run(VaadinService.java:469)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.vaadin.server.VaadinService.runPendingAccessTasks(VaadinService.java:1835)
        at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:990)
        at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1356)
        at org.vaadin.spring.servlet.Vaadin4SpringServletService.requestEnd(Vaadin4SpringServletService.java:84)
        at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1423)
        at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:237)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(AppliclterChain.java:207)
        at org.vaadin.spring.http.HttpResponseFilter.doFilter(HttpResponseFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter.doFilter(OAuth2ClientContextFilter.java:60)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:112)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChaiter(FilterChainProxy.java:330)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
07:33:41.209 [http-nio-8080-exec-7] DEBUG c.vaadin.spring.internal.UIScopeImpl/detach UI [com.basf.gb.cube.seq.vaadinui.MyVaadinUI@a27a41e] has been detached, destroying [UIBeanStore
[id=4df03526, name=UI:0]]
07:33:41.210 [http-nio-8080-exec-7] DEBUG com.vaadin.spring.internal.BeanStore/destroy Destroying [UIBeanStore[id=4df03526, name=UI:0]]
07:33:41.211 [http-nio-8080-exec-7] DEBUG c.v.s.internal.UIScopeImpl$UIStore/sessionDestroy Vaadin session has been destroyed, destroying [UIStore[id=36f84595, sessionId=55AF0F6E983B
2291A8F9DBE9AA370163]]
07:33:41.212 [http-nio-8080-exec-7] DEBUG c.v.s.i.VaadinSessionScope$SessionAwareBeanStore/sessionDestroy Vaadin session has been destroyed, destroying [SessionAwareBeanStore[id=6275
7279, name=Session:55AF0F6E983B2291A8F9DBE9AA370163]]

2 个答案:

答案 0 :(得分:2)

这是一个Tomcat错误,请参阅https://bz.apache.org/bugzilla/show_bug.cgi?id=59014

请升级到Tomcat版本8.0.33或7.0.69

答案 1 :(得分:0)

亚历山大的回答是正确的。您需要升级8.0.33才能解决此问题,这就是我设法为Spring Boot和Gradle更改Tomcat版本的方法。

  compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
  }
  //Because of the websocket defect on tomcat, I comment out the below line 
  //providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
  compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-el:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-websocket:8.0.33'