You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConfiguringPushForYourEnvironment.asciidoc 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. ---
  2. title: Configuring Push For Your Environment
  3. order: 15
  4. layout: page
  5. ---
  6. [[configuring-push-for-your-environment]]
  7. = Configuring push for your environment
  8. Server push and especially websockets are emerging technologies and not
  9. all servers and browsers handle them correctly (or even close to
  10. correctly). Here are gathered a few known issues and ways to work around
  11. them:
  12. *Rule of thumb: Use the latest version of your server and the latest
  13. Vaadin version. Vaadin 7.6 has a completely rewritten logic for dealing
  14. with buffering proxies and unreliabilities in the connection to the
  15. server.*
  16. [[portals]]
  17. Portals
  18. ~~~~~~~
  19. Push is not supported in portals.
  20. See https://dev.vaadin.com/ticket/11493 for more information.
  21. [[streaming]]
  22. Streaming
  23. ~~~~~~~~~
  24. *Avoid streaming and use long-polling instead*. Streaming and
  25. long-polling works similarly on top of normal HTTP requests but
  26. streaming uses the same HTTP response for multiple messages whereas
  27. long-polling only writes on message per HTTP response. Especially
  28. proxies can cause problems with streaming as they might deliver only
  29. part of the message and buffer the rest.
  30. [[tomcat-6-streaming]]
  31. Tomcat 6 + Streaming
  32. ~~~~~~~~~~~~~~~~~~~~
  33. For Tomcat 6, falling back to streaming always results in an error message such as
  34. [source]
  35. ....
  36. Failed using comet support: org.atmosphere.container.TomcatCometSupport, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat.jar Is the Nio or Apr Connector enabled?WARNING: Using org.atmosphere.container.BlockingIOCometSupport
  37. ....
  38. Atmosphere is expecting the Servlet to implement Tomcat's proprietary interface https://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/CometProcessor.html[CometProcessor]. (See https://github.com/Atmosphere/atmosphere/blob/atmosphere-project-1.0.14/modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereServlet.java[AtmosphereServlet])
  39. Vaadin's default servlet does not implement this interface.
  40. When fallback to native Comet fails, Atmosphere uses
  41. `BlockingIOCometSupport`, which seems to work with some applications and
  42. not with others. If it does not work for your application, you may want
  43. to try Tomcat 7 with a Servlet 3.0 application.
  44. [[tomcat-7-streaming]]
  45. Tomcat 7 + Streaming
  46. ~~~~~~~~~~~~~~~~~~~~
  47. For Tomcat 7, if your application is a Servlet 3.0 application, set the
  48. property `org.atmosphere.useWebSocketAndServlet3=true` and make sure
  49. your Servlet and your filters in Web.xml have
  50. `<async-supported>true</async-supported>` or the equivalent annotation.
  51. For Servlet < 3.0, see "Tomcat6 + Streaming" above.
  52. [[tomcat-7-websockets]]
  53. Tomcat 7 + Websockets
  54. ~~~~~~~~~~~~~~~~~~~~~
  55. Tomcat 7 is unable to share the HTTP session between HTTP request and
  56. websockets request. Because of this a FakeHttpSession (a copy of the
  57. real session) is used for websockets. This has certain implications such
  58. as that it is impossible to invalidate the session from a websockets
  59. enabled application. Tomcat 8 does not have this problem.
  60. The Websockets implementation in the 7.0.2x series is rather immature,
  61. so all kinds of issues may occur. 
  62. If you use Tomcat 7, upgrade to the latest version!
  63. *It is recommended to upgrade to the latest Tomcat 8 (requires Vaadin
  64. 7.2+) if you want to use websockets.*
  65. [[tomcat-8-websockets]]
  66. Tomcat 8 + Websockets
  67. ~~~~~~~~~~~~~~~~~~~~~
  68. ....
  69. java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.WebSocketFactory$Acceptor
  70. ....
  71. This implies you have Jetty deployed on the classpath somewhere.
  72. Atmosphere gets confused and tries to use its Websocket implementation
  73. instead of Tomcat's. One common reason for this is that you have
  74. accidentally deployed vaadin-client-compiler, which has Jetty as a
  75. dependency (needed by SuperDevMode for instance.)
  76. [[glassfish-234-streaming]]
  77. Glassfish 2/3/4 + Streaming
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. Glassfish 2/3/4 requires the "comet" option to be enabled for streaming
  80. to work.
  81. For Glassfish 2, set
  82. `(Configurations -> HTTP service -> HTTP listeners -> http-listener-1 -> Add Property -> "cometSupport"="true")`
  83. or use
  84. `asadmin set server.http-service.http-listener.http-listener-1.property.cometSupport=true`
  85. For Glassfish 3/4, set
  86. `(Configurations -> server-config -> Network Config -> Protocols -> http-listener-1 -> HTTP -> Comet Support)`
  87. or use
  88. `asadmin set server-config.network-config.protocols.protocol.http-listener-1.http.comet-support-enabled="true"`
  89. [[glassfish-3-websockets]]
  90. Glassfish 3 + Websockets
  91. ~~~~~~~~~~~~~~~~~~~~~~~~
  92. As a rule of thumb, don't do this.
  93. The Grizzly version shipped with Glassfish 3.1.2.2 contains a
  94. https://github.com/javaee/grizzly/issues/1289[fatal bug] which prevents
  95. Vaadin from working. Replace *glassfish/modules/grizzly-websockets.jar*
  96. with
  97. http://central.maven.org/maven2/com/sun/grizzly/grizzly-websockets/1.9.56/grizzly-websockets-1.9.56.jar
  98. to get websockets working (with Vaadin 7.3). *This version is actually
  99. also broken in many ways, so you may or may not get it to work. If you
  100. want websockets, you should upgrade to Glassfish 4.*
  101. Glassfish 3 requires the websockets option to be enabled for websockets
  102. to work
  103. `(Configurations -> server-config -> Network Config -> Protocols -> http-listener-1 -> HTTP -> Websockets Support)`
  104. or
  105. `asadmin set server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled="true"`.
  106. [[glassfish-4-websockets]]
  107. Glassfish 4 + Websockets
  108. ~~~~~~~~~~~~~~~~~~~~~~~~
  109. Glassfish 4 + websockets require Vaadin 7.2+. *If you are using
  110. Glassfish 4.0, upgrade to Glassfish 4.1 to avoid problems*
  111. [[wildfly-8-websockets]]
  112. Wildfly 8 + Websockets
  113. ~~~~~~~~~~~~~~~~~~~~~~
  114. Wildfly requires all websocket endpoints to be deployed during web
  115. application initialization and refuses to deploy them later. If you are
  116. using multiple push enabled Vaadin servlets you should mark them as
  117. load-on-startup=true to avoid issues. (Vaadin 7.2-7.4). Vaadin 7.5 fixes
  118. this by initializing websockets during context deployment so
  119. load-on-startup is not needed.
  120. [[weblogic-12-websockets]]
  121. Weblogic 12 + Websockets
  122. ~~~~~~~~~~~~~~~~~~~~~~~~
  123. Use WebLogic 12.1.3 or newer with Java 8 and Vaadin 7.5+.
  124. If you see "java.lang.IllegalStateException:
  125. javax.websocket.server.ServerContainer is null. Make sure you are using
  126. 1.8+ and your server has websocket support enabled" you are probably
  127. running with Java 7 or older.
  128. WebLogic 12 specifies a timeout of 30s by default for websocket
  129. connections
  130. (https://docs.oracle.com/middleware/1212/wls/WLPRG/websockets.htm#WLPRG811).
  131. To avoid constant reconnects, you can set the init
  132. parameter `weblogic.websocket.tyrus.session-max-idle-timeout` to either
  133. -1 (no timeout in use) or a higher value than 30000 (value is in ms).
  134. [[jboss-eap-6.4-and-websockets]]
  135. JBoss EAP 6.4  and Websockets
  136. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. JBoss EAP 6.4 includes support for websockets but they are not enabled
  138. by default. To make websockets work you need to
  139. 1. Change JBoss to use the NIO connector
  140. +
  141. This can be done by running
  142. +
  143. `$ bin/jboss-cli.sh --connect`
  144. +
  145. and the following commands
  146. +
  147. ....
  148. batch
  149. /subsystem=web/connector=http/:write-attribute(name=protocol,value=org.apache.coyote.http11.Http11NioProtocol)
  150. run-batch
  151. :reload
  152. ....
  153. 2. Add a *WEB-INF/jboss-web.xml* to you war file with the following
  154. contents to enable websockets
  155. [source,xml]
  156. ....
  157. <jboss-web version="7.2" xmlns="http://www.jboss.com/xml/ns/javaee"
  158. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  159. xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee schema/jboss-web_7_2.xsd">
  160. <enable-websockets>true</enable-websockets>
  161. </jboss-web>
  162. ....
  163. [[liberty-profileand-websockets]]
  164. Liberty profile and Websockets
  165. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  166. Use Liberty beta 2015.9.0.0 or later and Vaadin 7.6+.
  167. [[buffering-proxies-and-long-polling]]
  168. Buffering proxies and long polling
  169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. Use Vaadin 7.6+ to deal with buffering proxies. Also see "Duplicate
  171. resource xyz-abc-def-ghi-jkl" below
  172. [[kaspersky-anti-virus-long-polling]]
  173. Kaspersky anti virus + long polling
  174. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  175. Use Vaadin 7.6+ to avoid problems with long polling.
  176. [[chrome-sayserr_incomplete_chunked_encoding]]
  177. Chrome says ERR_INCOMPLETE_CHUNKED_ENCODING
  178. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. This is completely normal and means that the (long-polling) push
  180. connection was aborted by a third party. This typically happens when
  181. there is a proxy between the browser and the server and the proxy has a
  182. configured timeout and cuts the connection when the timeout is reached.
  183. The browser should reconnect to the server normally after this happens.
  184. Server logs contain
  185. ....
  186. Duplicate resource xyz-abc-def-ghi-jkl. Could be
  187. caused by a dead connection not detected by your server. Replacing the
  188. old one with the fresh one"
  189. ....
  190. This indicates that first, the browser connected to the server and used
  191. the given identifier for the push connection. Everything went as
  192. expected. Later on, a browser (probably the same one) connected again using the
  193. same identifier but according to the server, the old browser connection
  194. should still be active. The server closes the old connection and logs
  195. the warning.
  196. [[why-does-this-happen]]
  197. Why does this happen?
  198. ^^^^^^^^^^^^^^^^^^^^^
  199. Typically there was a proxy between the browser and the server, and the
  200. proxy was configured to kill open connections after a certain inactivity
  201. timeout on the connection (no data is sent before the server issues a
  202. push command). Because of how TCP/IP works, the server has no idea that
  203. the connection has been killed and continues to think that the old
  204. client is connected and all is well.
  205. [[what-can-you-do-to-avoid-this]]
  206. What can you do to avoid this?
  207. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  208. You have a couple of options:
  209. 1. If you are in control of the proxy, configure it not to timeout/kill
  210. push connections (connections to the /PUSH url)
  211. 2. If you know what the proxy timeout is, configure a slightly shorter
  212. timeout for push in the Vaadin application so that the server terminates
  213. the idle connection and is aware of the termination before the proxy can
  214. kill the connection. Use the `pushLongPollingSuspendTimeout` servlet
  215. parameter for this (defined in milliseconds) (Vaadin 7.6+)
  216. If you do not configure the proxy so that the server knows when the
  217. connection is killed, you also have a small chance of losing pushed
  218. data. If it so happens that the server does a push right after the
  219. connection was killed, it will not realize that it pushed data into a
  220. closed connection (because of how sockets work and especially how they
  221. work in Java). Disabling the timeout or setting the timeout on the
  222. server also resolves this potential issue.