Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Nuts and Bolts of WebSocket Devoxx 2014

13,203 views

Published on

Nuts and Bolts of WebSocket Devoxx 2014

Published in: Technology
  • Follow the link, new dating source: ❤❤❤ http://bit.ly/36cXjBY ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❤❤❤ http://bit.ly/36cXjBY ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Nuts and Bolts of WebSocket Devoxx 2014

  1. 1. Nuts and Bolts of WebSocket Arun Gupta, Red Hat, @arungupta Peter Moskovits, Kaazing, @peterm_kaazing @#Devoxx #WebSocket arungupta @peterm_kaazing
  2. 2. Agenda • Introduction • WebSocket and Node.js • WebSocket using JSR 356 • Server • Client • Securing WebSocket • Embedded WebSocket • Load Balance WebSocket • Pub/Sub over WebSocket • STOMP over WebSocket • MQTT over WebSocket • REST and SSE • Scalability • Debugging • Production Tips #Devoxx #WebSocket 2 @arungupta @peterm_kaazing
  3. 3. The “long” story of WebSocket #Devoxx #WebSocket 3 @arungupta @peterm_kaazing
  4. 4. “Limitations” of HTTP #Devoxx #WebSocket 4 @arungupta @peterm_kaazing
  5. 5. “Limitations” of HTTP • Client-driven #Devoxx #WebSocket 4 @arungupta @peterm_kaazing
  6. 6. “Limitations” of HTTP • Client-driven • Half-duplex #Devoxx #WebSocket 4 @arungupta @peterm_kaazing
  7. 7. “Limitations” of HTTP • Client-driven • Half-duplex • Verbose #Devoxx #WebSocket 4 @arungupta @peterm_kaazing
  8. 8. “Limitations” of HTTP • Client-driven • Half-duplex • Verbose • New TCP connection #Devoxx #WebSocket 4 @arungupta @peterm_kaazing
  9. 9. “Hello World” HTTP POST /websocket-vs-rest-payload/webresources/rest HTTP/1.1rn Host: localhost:8080rn Connection: keep-alivern Content-Length: 11rn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36rn Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloorn Content-Type: text/plain rn Accept: */*rn Accept-Encoding: gzip,deflate,sdchrn Accept-Language: en-US,en;q=0.8rn rn HTTP/1.1 200 OKrn Connection: keep-alivern X-Powered-By: Undertow 1rn Server: Wildfly 8 rn Content-Type: text/plainrn Content-Length: 11 rn Date: Fri, 21 Feb 2014 21:27:53 GMT rn rn #Devoxx #WebSocket 5 @arungupta @peterm_kaazing
  10. 10. “Hello World” HTTP POST /websocket-vs-rest-payload/webresources/rest HTTP/1.1rn Host: localhost:8080rn Connection: keep-alivern Content-Length: 11rn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36rn Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloorn Content-Type: text/plain rn Accept: */*rn Accept-Encoding: gzip,deflate,sdchrn Accept-Language: en-US,en;q=0.8rn rn HTTP/1.1 200 OKrn Connection: keep-alivern X-Powered-By: Undertow 1rn Server: Wildfly 8 rn Content-Type: text/plainrn Content-Length: 11 rn Date: Fri, 21 Feb 2014 21:27:53 GMT rn rn 663 bytes #Devoxx #WebSocket 5 @arungupta @peterm_kaazing
  11. 11. How WebSocket solves it ? #Devoxx #WebSocket 6 @arungupta @peterm_kaazing
  12. 12. How WebSocket solves it ? • Bi-directional (client-driven) #Devoxx #WebSocket 6 @arungupta @peterm_kaazing
  13. 13. How WebSocket solves it ? • Bi-directional (client-driven) • Full-duplex (half-duplex) #Devoxx #WebSocket 6 @arungupta @peterm_kaazing
  14. 14. How WebSocket solves it ? • Bi-directional (client-driven) • Full-duplex (half-duplex) • Lean protocol (verbose) #Devoxx #WebSocket 6 @arungupta @peterm_kaazing
  15. 15. How WebSocket solves it ? • Bi-directional (client-driven) • Full-duplex (half-duplex) • Lean protocol (verbose) • Single TCP connection (new TCP) #Devoxx #WebSocket 6 @arungupta @peterm_kaazing
  16. 16. What is WebSocket ? #Devoxx #WebSocket 7 @arungupta @peterm_kaazing
  17. 17. What is WebSocket ? • Bi-directional, full-duplex, communication channel over a single TCP connection #Devoxx #WebSocket 7 @arungupta @peterm_kaazing
  18. 18. What is WebSocket ? • Bi-directional, full-duplex, communication channel over a single TCP connection • Originally proposed as part of HTML5 #Devoxx #WebSocket 7 @arungupta @peterm_kaazing
  19. 19. What is WebSocket ? • Bi-directional, full-duplex, communication channel over a single TCP connection • Originally proposed as part of HTML5 • IETF-defined Protocol: RFC 6455 #Devoxx #WebSocket 7 @arungupta @peterm_kaazing
  20. 20. What is WebSocket ? • Bi-directional, full-duplex, communication channel over a single TCP connection • Originally proposed as part of HTML5 • IETF-defined Protocol: RFC 6455 • W3C-defined JavaScript API #Devoxx #WebSocket 7 @arungupta @peterm_kaazing
  21. 21. How does it work ? #Devoxx #WebSocket 8 @arungupta @peterm_kaazing
  22. 22. How does it work ? • Upgrade HTTP to WebSocket (single TCP connection) #Devoxx #WebSocket 8 @arungupta @peterm_kaazing
  23. 23. How does it work ? • Upgrade HTTP to WebSocket (single TCP connection) • Send data frames in both direction (bi-directional) #Devoxx #WebSocket 8 @arungupta @peterm_kaazing
  24. 24. How does it work ? • Upgrade HTTP to WebSocket (single TCP connection) • Send data frames in both direction (bi-directional) • Send messages independent of each other (full-duplex) #Devoxx #WebSocket 8 @arungupta @peterm_kaazing
  25. 25. How does it work ? • Upgrade HTTP to WebSocket (single TCP connection) • Send data frames in both direction (bi-directional) • Send messages independent of each other (full-duplex) • End the connection #Devoxx #WebSocket 8 @arungupta @peterm_kaazing
  26. 26. How does it work ? Client Server #Devoxx #WebSocket 9 @arungupta @peterm_kaazing
  27. 27. How does it work ? HTTP Client Server #Devoxx #WebSocket 9 @arungupta @peterm_kaazing
  28. 28. How does it work ? HTTP HTTP Client Server #Devoxx #WebSocket 9 @arungupta @peterm_kaazing
  29. 29. How does it work ? HTTP HTTP Client Server Handshake Request #Devoxx #WebSocket 9 @arungupta @peterm_kaazing
  30. 30. How does it work ? HTTP HTTP Client Server Handshake Request Handshake Response #Devoxx #WebSocket 9 @arungupta @peterm_kaazing
  31. 31. Handshake Request GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Origin: http://example.com Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 #Devoxx #WebSocket 10 @arungupta @peterm_kaazing
  32. 32. Handshake Request GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Origin: http://example.com Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 #Devoxx #WebSocket 10 @arungupta @peterm_kaazing
  33. 33. Handshake Request GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Origin: http://example.com Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 #Devoxx #WebSocket 10 @arungupta @peterm_kaazing
  34. 34. Handshake Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat #Devoxx #WebSocket 11 @arungupta @peterm_kaazing
  35. 35. Handshake Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat #Devoxx #WebSocket 11 @arungupta @peterm_kaazing
  36. 36. Handshake Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat #Devoxx #WebSocket 11 @arungupta @peterm_kaazing
  37. 37. How does it work ? Handshake Request Handshake Response Client WebSocket Server #Devoxx #WebSocket 12 @arungupta @peterm_kaazing
  38. 38. How does it work ? Handshake Request Handshake Response WebSocket Peer (Client) Peer (Server) #Devoxx #WebSocket 12 @arungupta @peterm_kaazing
  39. 39. How does it work ? WebSocket Peer (Client) Peer (Server) #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  40. 40. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  41. 41. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  42. 42. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage onMessage #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  43. 43. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage onMessage onError #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  44. 44. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage onMessage onError onMessage #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  45. 45. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage onMessage onError onMessage onClose #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  46. 46. How does it work ? WebSocket onOpen onOpen Peer (Client) Peer (Server) onMessage onMessage onError onMessage onClose Disconnected #Devoxx #WebSocket 13 @arungupta @peterm_kaazing
  47. 47. WebSocket Subprotocols #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  48. 48. WebSocket Subprotocols • Facilitates application layer protocols #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  49. 49. WebSocket Subprotocols • Facilitates application layer protocols • Registered in a Subprotocol name registry #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  50. 50. WebSocket Subprotocols • Facilitates application layer protocols • Registered in a Subprotocol name registry • Identifier, common name, definition #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  51. 51. WebSocket Subprotocols • Facilitates application layer protocols • Registered in a Subprotocol name registry • Identifier, common name, definition • www.iana.org/assignments/websocket/websocket.xml#subprotocol-name #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  52. 52. WebSocket Subprotocols • Facilitates application layer protocols • Registered in a Subprotocol name registry • Identifier, common name, definition • www.iana.org/assignments/websocket/websocket.xml#subprotocol-name • STOMP, XMPP, MQTT, SOAP, … #Devoxx #WebSocket 14 @arungupta @peterm_kaazing
  53. 53. WebSocket Extensions #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  54. 54. WebSocket Extensions • Add capabilities to the base protocol #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  55. 55. WebSocket Extensions • Add capabilities to the base protocol • Multiplexing http://tools.ietf.org/html/draft-tamplin-hybi-google-mux #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  56. 56. WebSocket Extensions • Add capabilities to the base protocol • Multiplexing http://tools.ietf.org/html/draft-tamplin-hybi-google-mux • Compression: Only non-control frames/messages #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  57. 57. WebSocket Extensions • Add capabilities to the base protocol • Multiplexing http://tools.ietf.org/html/draft-tamplin-hybi-google-mux • Compression: Only non-control frames/messages • Per-frame http://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  58. 58. WebSocket Extensions • Add capabilities to the base protocol • Multiplexing http://tools.ietf.org/html/draft-tamplin-hybi-google-mux • Compression: Only non-control frames/messages • Per-frame http://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate • Per-message http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression #Devoxx #WebSocket 15 @arungupta @peterm_kaazing
  59. 59. WebSocket JavaScript API www.w3.org/TR/websockets #Devoxx #WebSocket 16 @arungupta @peterm_kaazing
  60. 60. Support in Browsers caniuse.com/websockets #Devoxx #WebSocket 17 @arungupta @peterm_kaazing
  61. 61. Developer Tools @#Devoxx #WebSocket 18 arungupta @peterm_kaazing
  62. 62. @#Devoxx #WebSocket 19 arungupta @peterm_kaazing
  63. 63. Java API for WebSocket #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  64. 64. Java API for WebSocket • API for WebSocket server and client endpoint #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  65. 65. Java API for WebSocket • API for WebSocket server and client endpoint • Annotated: @ServerEndpoint, @ClientEndpoint #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  66. 66. Java API for WebSocket • API for WebSocket server and client endpoint • Annotated: @ServerEndpoint, @ClientEndpoint • Programmatic: Endpoint #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  67. 67. Java API for WebSocket • API for WebSocket server and client endpoint • Annotated: @ServerEndpoint, @ClientEndpoint • Programmatic: Endpoint • WebSocket opening handshake negotiation #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  68. 68. Java API for WebSocket • API for WebSocket server and client endpoint • Annotated: @ServerEndpoint, @ClientEndpoint • Programmatic: Endpoint • WebSocket opening handshake negotiation • Lifecycle Callback methods #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  69. 69. Java API for WebSocket • API for WebSocket server and client endpoint • Annotated: @ServerEndpoint, @ClientEndpoint • Programmatic: Endpoint • WebSocket opening handshake negotiation • Lifecycle Callback methods • Integration with Java EE technologies #Devoxx #WebSocket 20 @arungupta @peterm_kaazing
  70. 70. Annotated Endpoint import javax.websocket.*; @ServerEndpoint("/hello") public class HelloBean { @OnMessage public String sayHello(String name) { return "Hello " + name; } #Devoxx #WebSocket 21 @arungupta @peterm_kaazing
  71. 71. WebSocket Annotations • Class-level annotations • @ServerEndpoint: Turns a POJO in a server endpoint • @ClientEndpoint: Turns a POJO in a client endpoint #Devoxx #WebSocket 22 @arungupta @peterm_kaazing
  72. 72. WebSocket Annotations • Method-level annotations • @OnMessage: Intercepts WebSocket messages • @OnOpen: Intercepts WebSocket open events • @OnClose: Intercepts WebSocket close events • @OnError: Intercepts WebSocket error events #Devoxx #WebSocket 23 @arungupta @peterm_kaazing
  73. 73. WebSocket Annotations • Parameter-level annotations • @PathParam: Matches path segment of a URI-template #Devoxx #WebSocket 24 @arungupta @peterm_kaazing
  74. 74. @ServerEndpoint attributes #Devoxx #WebSocket 25 @arungupta @peterm_kaazing
  75. 75. @ServerEndpoint attributes • value: Relative URI or URI template e.g. ‘/hello’ or ‘/chat/ {subscriber-level}’ #Devoxx #WebSocket 25 @arungupta @peterm_kaazing
  76. 76. @ServerEndpoint attributes • value: Relative URI or URI template e.g. ‘/hello’ or ‘/chat/ {subscriber-level}’ • decoders: list of message decoder classnames #Devoxx #WebSocket 25 @arungupta @peterm_kaazing
  77. 77. @ServerEndpoint attributes • value: Relative URI or URI template e.g. ‘/hello’ or ‘/chat/ {subscriber-level}’ • decoders: list of message decoder classnames • encoders: list of message encoder classnames #Devoxx #WebSocket 25 @arungupta @peterm_kaazing
  78. 78. @ServerEndpoint attributes • value: Relative URI or URI template e.g. ‘/hello’ or ‘/chat/ {subscriber-level}’ • decoders: list of message decoder classnames • encoders: list of message encoder classnames • subprotocols: list of the names of the supported subprotocols #Devoxx #WebSocket 25 @arungupta @peterm_kaazing
  79. 79. Chat Server @ServerEndpoint("/chat") public class ChatBean { static Set<Session> peers = Collections.synchronizedSet("..."); @OnOpen public void onOpen(Session peer) { peers.add(peer); } @OnClose public void onClose(Session peer) { peers.remove(peer); } @OnMessage public void message(String message) { for (Session peer : peers) { peer.getBasicRemote().sendObject(message); } } } #Devoxx #WebSocket 26 @arungupta @peterm_kaazing
  80. 80. Chat Server Simplified @ServerEndpoint("/chat") public class ChatBean { @OnMessage public void message(String message, Session endpoint) { for (Session peer : endpoint.getOpenSessions()) { peer.getBasicRemote().sendObject(message); } } } #Devoxx #WebSocket 27 @arungupta @peterm_kaazing
  81. 81. Hello there! Howdy? https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/chat #Devoxx #WebSocket 28 @arungupta @peterm_kaazing
  82. 82. Custom Payloads @ServerEndpoint( value="/hello", decoders={MyMessageDecoder.class}, encoders={MyMessageEncoder.class} ) public class MyEndpoint { . . . } #Devoxx #WebSocket 29 @arungupta @peterm_kaazing
  83. 83. Custom Payloads: Text decoder public class MyMessageDecoder implements Decoder.Text<MyMessage> { public MyMessage decode(String s) { JsonObject jsonObject = Json.createReader("...").readObject(); return new MyMessage(jsonObject); } public boolean willDecode(String string) { . . . return true; } . . . } #Devoxx #WebSocket 30 @arungupta @peterm_kaazing
  84. 84. Custom Payloads: Text encoder public class MyMessageDecoder implements Encoder.Text<MyMessage> { public String encode(MyMessage myMessage) { return myMessage.jsonObject.toString(); } . . . } #Devoxx #WebSocket 31 @arungupta @peterm_kaazing
  85. 85. Custom Payloads: Binary decoder public class MyMessageDecoder implements Decoder.Binary<MyMessage> { public MyMessage decode(byte[] s) { . . . return myMessage; } public boolean willDecode(byte[] string) { . . . return true; } . . . } #Devoxx #WebSocket 32 @arungupta @peterm_kaazing
  86. 86. Method Signatures #Devoxx #WebSocket 33 @arungupta @peterm_kaazing
  87. 87. Method Signatures • Exactly one of the following • Text: String, boolean, Java primitive or equivalent class, Reader, any type for which there is a decoder • Binary: byte[], ByteBuffer, byte[] and boolean, ByteBuffer and boolean, InputStream, any type for which there is a decoder • Pong messages: PongMessage #Devoxx #WebSocket 33 @arungupta @peterm_kaazing
  88. 88. Method Signatures • Exactly one of the following • Text: String, boolean, Java primitive or equivalent class, Reader, any type for which there is a decoder • Binary: byte[], ByteBuffer, byte[] and boolean, ByteBuffer and boolean, InputStream, any type for which there is a decoder • Pong messages: PongMessage • An optional Session parameter #Devoxx #WebSocket 33 @arungupta @peterm_kaazing
  89. 89. Method Signatures • Exactly one of the following • Text: String, boolean, Java primitive or equivalent class, Reader, any type for which there is a decoder • Binary: byte[], ByteBuffer, byte[] and boolean, ByteBuffer and boolean, InputStream, any type for which there is a decoder • Pong messages: PongMessage • An optional Session parameter • 0..n String parameters annotated with @PathParam #Devoxx #WebSocket 33 @arungupta @peterm_kaazing
  90. 90. Method Signatures • Exactly one of the following • Text: String, boolean, Java primitive or equivalent class, Reader, any type for which there is a decoder • Binary: byte[], ByteBuffer, byte[] and boolean, ByteBuffer and boolean, InputStream, any type for which there is a decoder • Pong messages: PongMessage • An optional Session parameter • 0..n String parameters annotated with @PathParam #Devoxx #WebSocket 33 @arungupta @peterm_kaazing
  91. 91. Sample Messages #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  92. 92. Sample Messages •void m(String s); #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  93. 93. Sample Messages •void m(String s); •void m(Float f, @PathParam(“id”)int id); #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  94. 94. Sample Messages •void m(String s); •void m(Float f, @PathParam(“id”)int id); •Product m(Reader reader, Session s); #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  95. 95. Sample Messages •void m(String s); •void m(Float f, @PathParam(“id”)int id); •Product m(Reader reader, Session s); •void m(byte[] b); or void m(ByteBuffer b); #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  96. 96. Sample Messages •void m(String s); •void m(Float f, @PathParam(“id”)int id); •Product m(Reader reader, Session s); •void m(byte[] b); or void m(ByteBuffer b); •Book m(int i, Session s, @PathParam(“isbn”)String isbn, @PathParam(“store”)String store); #Devoxx #WebSocket 34 @arungupta @peterm_kaazing
  97. 97. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  98. 98. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  99. 99. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  100. 100. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  101. 101. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  102. 102. @#Devoxx #WebSocket 35 arungupta @peterm_kaazing
  103. 103. https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/whiteboard #Devoxx #WebSocket 35 @arungupta @peterm_kaazing
  104. 104. URI Template Matching @ServerEndpoint("/chat/{roomid}") public class ChatServer { @OnMessage public void receiveMessage( @PathParam("roomid")String roomId) { . . . } } #Devoxx #WebSocket 36 @arungupta @peterm_kaazing
  105. 105. Client Endpoint @ClientEndpoint public class HelloClient { @OnMessage public void message( String message, Session session) { //. . . } } #Devoxx #WebSocket 37 @arungupta @peterm_kaazing
  106. 106. Client Endpoint @ClientEndpoint public class HelloClient { @OnMessage public void message( String message, Session session) { //. . . } } WebSocketContainer c = ContainerProvider.getWebSocketContainer(); c.connectToServer(HelloClient.class, "hello"); #Devoxx #WebSocket 37 @arungupta @peterm_kaazing
  107. 107. lorem ipsum dolor lorem ipsum dolor https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/google-docs #Devoxx #WebSocket 38 @arungupta @peterm_kaazing
  108. 108. Programmatic Endpoint public class ChatServer extends Endpoint { @Override public void onOpen(Session session) { session.addMessageHandler(new MessageHandler.Text() { public void onMessage(String message) { try { session .getBasicRemote() .sendText(message); } catch (IOException ex) { } } }); } } #Devoxx #WebSocket 39 @arungupta @peterm_kaazing
  109. 109. Programmatic Endpoint Config public class MyEndpointConfig implements ServerApplicationConfig { @Override public Set<ServerEndpointConfig> getEndpointConfigs( Set<Class<? extends Endpoint>> set) { return new HashSet<ServerEndpointConfig>() { { add(ServerEndpointConfig.Builder .create(ChatServer.class, "/chat") .build()); } }; } @Override public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> set) { return Collections.emptySet(); } } #Devoxx #WebSocket 40 @arungupta @peterm_kaazing
  110. 110. https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/endpoint-singleton #Devoxx #WebSocket 41 @arungupta @peterm_kaazing
  111. 111. Securing WebSockets #Devoxx #WebSocket 42 @arungupta @peterm_kaazing
  112. 112. Securing WebSockets • Origin-based security model #Devoxx #WebSocket 42 @arungupta @peterm_kaazing
  113. 113. Securing WebSockets • Origin-based security model • Sec-xxx keys can not be set using XMLHttpRequest • Sec-WebSocket-Key, Sec-WebSocket-Version #Devoxx #WebSocket 42 @arungupta @peterm_kaazing
  114. 114. Securing WebSockets • Origin-based security model • Sec-xxx keys can not be set using XMLHttpRequest • Sec-WebSocket-Key, Sec-WebSocket-Version • User-based security using Servlet security mechanism • Endpoint mapped by ws:// is protected using security model defined using the corresponding http:// URI • Authorization defined using <security-constraint> #Devoxx #WebSocket 42 @arungupta @peterm_kaazing
  115. 115. Securing WebSockets • Origin-based security model • Sec-xxx keys can not be set using XMLHttpRequest • Sec-WebSocket-Key, Sec-WebSocket-Version • User-based security using Servlet security mechanism • Endpoint mapped by ws:// is protected using security model defined using the corresponding http:// URI • Authorization defined using <security-constraint> • Transport Confidentiality using wss:// • Access allowed over encrypted connection only #Devoxx #WebSocket 42 @arungupta @peterm_kaazing
  116. 116. Cross-Origin Resource Sharing #Devoxx #WebSocket 43 @arungupta @peterm_kaazing
  117. 117. Cross-Origin Resource Sharing • Relaxes same-origin restrictions to network requests #Devoxx #WebSocket 43 @arungupta @peterm_kaazing
  118. 118. Cross-Origin Resource Sharing • Relaxes same-origin restrictions to network requests • Servers include Access-Control-Allow-Origin HTTP header #Devoxx #WebSocket 43 @arungupta @peterm_kaazing
  119. 119. Cross-Origin Resource Sharing • Relaxes same-origin restrictions to network requests • Servers include Access-Control-Allow-Origin HTTP header • Access-Control-* headers • Max-Age • Allow-Methods • Allow-Headers • … #Devoxx #WebSocket 43 @arungupta @peterm_kaazing
  120. 120. Cross-Origin Resource Sharing • Relaxes same-origin restrictions to network requests • Servers include Access-Control-Allow-Origin HTTP header • Access-Control-* headers • Max-Age • Allow-Methods • Allow-Headers • … • www.w3.org/TR/cors/ #Devoxx #WebSocket 43 @arungupta @peterm_kaazing
  121. 121. User-based Security https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/endpoint-security #Devoxx #WebSocket 44 @arungupta @peterm_kaazing
  122. 122. TLS-based Security https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/endpoint-wss #Devoxx #WebSocket 45 @arungupta @peterm_kaazing
  123. 123. Embedded WebSocket #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  124. 124. Embedded WebSocket • Undertow New web server in WildFly 8 #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  125. 125. Embedded WebSocket • Undertow New web server in WildFly 8 • Blocking and non-blocking based on NIO #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  126. 126. Embedded WebSocket • Undertow New web server in WildFly 8 • Blocking and non-blocking based on NIO • Composition/handler-based architecture #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  127. 127. Embedded WebSocket • Undertow New web server in WildFly 8 • Blocking and non-blocking based on NIO • Composition/handler-based architecture • Lightweight and fully embeddable #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  128. 128. Embedded WebSocket • Undertow New web server in WildFly 8 • Blocking and non-blocking based on NIO • Composition/handler-based architecture • Lightweight and fully embeddable • Supports Servlet 3.1 and HTTP Upgrade #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  129. 129. Embedded WebSocket • Undertow New web server in WildFly 8 • Blocking and non-blocking based on NIO • Composition/handler-based architecture • Lightweight and fully embeddable • Supports Servlet 3.1 and HTTP Upgrade • mod_cluster supported #Devoxx #WebSocket 46 @arungupta @peterm_kaazing
  130. 130. Undertow is awesome! http://www.techempower.com/blog/2014/03/04/one-million-http-rps-without-load-balancing-is-easy/ #Devoxx #WebSocket 47 @arungupta @peterm_kaazing
  131. 131. git@github.com:undertow-io/undertow.git #Devoxx #WebSocket 48 @arungupta @peterm_kaazing
  132. 132. Load Balance WebSocket #Devoxx #WebSocket 49 @arungupta @peterm_kaazing
  133. 133. Load Balance WebSocket • Reverse proxy #Devoxx #WebSocket 49 @arungupta @peterm_kaazing
  134. 134. Load Balance WebSocket • Reverse proxy • Apache module: mod_proxy_wstunnel #Devoxx #WebSocket 49 @arungupta @peterm_kaazing
  135. 135. Load Balance WebSocket • Reverse proxy • Apache module: mod_proxy_wstunnel • Only vertical scaling #Devoxx #WebSocket 49 @arungupta @peterm_kaazing
  136. 136. Load Balance WebSocket • Reverse proxy • Apache module: mod_proxy_wstunnel • Only vertical scaling • No session replication #Devoxx #WebSocket 49 @arungupta @peterm_kaazing
  137. 137. http://blog.arungupta.me/2014/08/load-balance-websockets-apache-httpd-techtip48/ #Devoxx #WebSocket 50 @arungupta @peterm_kaazing
  138. 138. Pub/Sub over WebSocket https://github.com/arun-gupta/kaazing-openshift-cartridge #Devoxx #WebSocket 51 @arungupta @peterm_kaazing
  139. 139. STOMP over WebSocket #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  140. 140. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  141. 141. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol • Interoperable wire format: any client, any broker #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  142. 142. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol • Interoperable wire format: any client, any broker • Messaging interoperability among languages and platforms #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  143. 143. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol • Interoperable wire format: any client, any broker • Messaging interoperability among languages and platforms • Unlike JMS #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  144. 144. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol • Interoperable wire format: any client, any broker • Messaging interoperability among languages and platforms • Unlike JMS • REST for messaging: CONNECT, SEND, SUBSCRIBE, . . . #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  145. 145. STOMP over WebSocket • STOMP: Simple Text Oriented Messaging Protocol • Interoperable wire format: any client, any broker • Messaging interoperability among languages and platforms • Unlike JMS • REST for messaging: CONNECT, SEND, SUBSCRIBE, . . . • Map STOMP frames to WebSocket frames #Devoxx #WebSocket 52 @arungupta @peterm_kaazing
  146. 146. https://github.com/arun-gupta/wildfly-samples/tree/master/websocket-stomp #Devoxx #WebSocket 53 @arungupta @peterm_kaazing
  147. 147. MQTT over WebSocket #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  148. 148. MQTT over WebSocket • Light-weight pub/sub messaging over TCP #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  149. 149. MQTT over WebSocket • Light-weight pub/sub messaging over TCP • Designed for “small foot print” or limited bandwidth #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  150. 150. MQTT over WebSocket • Light-weight pub/sub messaging over TCP • Designed for “small foot print” or limited bandwidth • MQTT 3.1.1 just became an OASIS standard #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  151. 151. MQTT over WebSocket • Light-weight pub/sub messaging over TCP • Designed for “small foot print” or limited bandwidth • MQTT 3.1.1 just became an OASIS standard • Plain byte array message payload #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  152. 152. MQTT over WebSocket • Light-weight pub/sub messaging over TCP • Designed for “small foot print” or limited bandwidth • MQTT 3.1.1 just became an OASIS standard • Plain byte array message payload • Quality-of-Service: 0 (TCP), 1 (at least once), 2 (missed messages) #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  153. 153. MQTT over WebSocket • Light-weight pub/sub messaging over TCP • Designed for “small foot print” or limited bandwidth • MQTT 3.1.1 just became an OASIS standard • Plain byte array message payload • Quality-of-Service: 0 (TCP), 1 (at least once), 2 (missed messages) • “Last will and testament” publish a message after client goes offline #Devoxx #WebSocket 54 @arungupta @peterm_kaazing
  154. 154. http://blog.kaazing.com/2013/10/01/controlling-physical-devices-on-the-real-time-web-kaazing-iot-talk-at-javaone-2013/ #Devoxx #WebSocket 55 @arungupta @peterm_kaazing
  155. 155. Compare with REST https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/websocket-vs-rest-payload https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/websocket-vs-rest #Devoxx #WebSocket 56 @arungupta @peterm_kaazing
  156. 156. Server-Sent Events #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  157. 157. Server-Sent Events • Part of HTML5 Specification #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  158. 158. Server-Sent Events • Part of HTML5 Specification • Server-push notifications #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  159. 159. Server-Sent Events • Part of HTML5 Specification • Server-push notifications • Cross-browser JavaScript API: EventSource #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  160. 160. Server-Sent Events • Part of HTML5 Specification • Server-push notifications • Cross-browser JavaScript API: EventSource • Message callbacks #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  161. 161. Server-Sent Events • Part of HTML5 Specification • Server-push notifications • Cross-browser JavaScript API: EventSource • Message callbacks • MIME type: text/eventstream #Devoxx #WebSocket 57 @arungupta @peterm_kaazing
  162. 162. EventSource API #Devoxx #WebSocket 58 @arungupta @peterm_kaazing
  163. 163. WebSockets and SSE ? #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  164. 164. WebSockets and SSE ? WebSocket Server-Sent Event #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  165. 165. WebSockets and SSE ? WebSocket Server-Sent Event Over a custom protocol Over simple HTTP #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  166. 166. WebSockets and SSE ? WebSocket Server-Sent Event Over a custom protocol Over simple HTTP Full-duplex, bi-directional Server-push only, client-server OOB #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  167. 167. WebSockets and SSE ? WebSocket Server-Sent Event Over a custom protocol Over simple HTTP Full-duplex, bi-directional Server-push only, client-server OOB Native support in most browsers Can be poly-filled to backport #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  168. 168. WebSockets and SSE ? WebSocket Server-Sent Event Over a custom protocol Over simple HTTP Full-duplex, bi-directional Server-push only, client-server OOB Native support in most browsers Can be poly-filled to backport Not straight forward protocol Simpler protocol #Devoxx #WebSocket 59 @arungupta @peterm_kaazing
  169. 169. WebSockets and SSE ? #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  170. 170. WebSockets and SSE ? WebSocket Server-Sent Event #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  171. 171. WebSockets and SSE ? WebSocket Server-Sent Event Application-specific reconnection Built-in support for reconnection and event id #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  172. 172. WebSockets and SSE ? WebSocket Server-Sent Event Application-specific reconnection Built-in support for reconnection and event id Require server and/or proxy configurations No server or proxy change required #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  173. 173. WebSockets and SSE ? WebSocket Server-Sent Event Application-specific reconnection Built-in support for reconnection and event id Require server and/or proxy configurations No server or proxy change required Text and Binary Text only #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  174. 174. WebSockets and SSE ? WebSocket Server-Sent Event Application-specific reconnection Built-in support for reconnection and event id Require server and/or proxy configurations No server or proxy change required Text and Binary Text only Pre-defined message handlers Pre-defined and arbitrary #Devoxx #WebSocket 60 @arungupta @peterm_kaazing
  175. 175. What makes them scalable ? #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  176. 176. What makes them scalable ? • No HTTP/TCP opening/closing connections #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  177. 177. What makes them scalable ? • No HTTP/TCP opening/closing connections • Handshake over a single TCP connection #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  178. 178. What makes them scalable ? • No HTTP/TCP opening/closing connections • Handshake over a single TCP connection • HTTP connections have short connection timeout (5 secs for Apache) #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  179. 179. What makes them scalable ? • No HTTP/TCP opening/closing connections • Handshake over a single TCP connection • HTTP connections have short connection timeout (5 secs for Apache) • Elimination of HTTP headers (cookies, content-type, user-agent, …) #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  180. 180. What makes them scalable ? • No HTTP/TCP opening/closing connections • Handshake over a single TCP connection • HTTP connections have short connection timeout (5 secs for Apache) • Elimination of HTTP headers (cookies, content-type, user-agent, …) • Reduces bandwidth dramatically #Devoxx #WebSocket 61 @arungupta @peterm_kaazing
  181. 181. What makes them scalable ? #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  182. 182. What makes them scalable ? • Minimal data framing #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  183. 183. What makes them scalable ? • Minimal data framing • 2-14 bytes overhead after handshake #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  184. 184. What makes them scalable ? • Minimal data framing • 2-14 bytes overhead after handshake • Maintaining a TCP connection on server is relatively inexpensive #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  185. 185. What makes them scalable ? • Minimal data framing • 2-14 bytes overhead after handshake • Maintaining a TCP connection on server is relatively inexpensive • Smaller data fragments can be sent without out a request/ response #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  186. 186. What makes them scalable ? • Minimal data framing • 2-14 bytes overhead after handshake • Maintaining a TCP connection on server is relatively inexpensive • Smaller data fragments can be sent without out a request/ response • Live pushes, e.g. stock sticker #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  187. 187. What makes them scalable ? • Minimal data framing • 2-14 bytes overhead after handshake • Maintaining a TCP connection on server is relatively inexpensive • Smaller data fragments can be sent without out a request/ response • Live pushes, e.g. stock sticker • Lower latency #Devoxx #WebSocket 62 @arungupta @peterm_kaazing
  188. 188. What makes them scalable ? #Devoxx #WebSocket 63 @arungupta @peterm_kaazing
  189. 189. What makes them scalable ? • WebSockets are good at scaling vertically #Devoxx #WebSocket 63 @arungupta @peterm_kaazing
  190. 190. What makes them scalable ? • WebSockets are good at scaling vertically • HTTP servers are typically configured to log start/completion of HTTP request, not so for WebSocket #Devoxx #WebSocket 63 @arungupta @peterm_kaazing
  191. 191. What makes them scalable ? • WebSockets are good at scaling vertically • HTTP servers are typically configured to log start/completion of HTTP request, not so for WebSocket • Polling and Long-polling is a waste of bandwidth, WebSockets are more elegant #Devoxx #WebSocket 63 @arungupta @peterm_kaazing
  192. 192. What makes them scalable ? • WebSockets are good at scaling vertically • HTTP servers are typically configured to log start/completion of HTTP request, not so for WebSocket • Polling and Long-polling is a waste of bandwidth, WebSockets are more elegant • Number of concurrent clients depend upon FD settings #Devoxx #WebSocket 63 @arungupta @peterm_kaazing
  193. 193. Debugging WebSockets #Devoxx #WebSocket 64 @arungupta @peterm_kaazing
  194. 194. @#Devoxx #WebSocket 65 arungupta @peterm_kaazing
  195. 195. @#Devoxx #WebSocket 66 arungupta @peterm_kaazing
  196. 196. Debugging WebSockets #Devoxx #WebSocket 67 @arungupta @peterm_kaazing
  197. 197. Production Tips #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  198. 198. Production Tips • Proxy can be evil and make WebSockets unusable #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  199. 199. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  200. 200. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header • Fix: Set timeout, remove after onOpen called #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  201. 201. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header • Fix: Set timeout, remove after onOpen called • Issue: Close connection after X idle time #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  202. 202. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header • Fix: Set timeout, remove after onOpen called • Issue: Close connection after X idle time • Fix: Application-level heartbeat #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  203. 203. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header • Fix: Set timeout, remove after onOpen called • Issue: Close connection after X idle time • Fix: Application-level heartbeat • Issue: Not allow to pass through at all #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  204. 204. Production Tips • Proxy can be evil and make WebSockets unusable • Issue: Remove “Upgrade” header • Fix: Set timeout, remove after onOpen called • Issue: Close connection after X idle time • Fix: Application-level heartbeat • Issue: Not allow to pass through at all • Fix: Fall back on long-polling #Devoxx #WebSocket 68 @arungupta @peterm_kaazing
  205. 205. Production Tips #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  206. 206. Production Tips • Load Balancer #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  207. 207. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  208. 208. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB • Fix: ELB configured to use TCP, but no session affinity #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  209. 209. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB • Fix: ELB configured to use TCP, but no session affinity • Browsers #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  210. 210. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB • Fix: ELB configured to use TCP, but no session affinity • Browsers • Issue: IE 6, 7, 8, 9 and Safari 5 do not support WebSocket #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  211. 211. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB • Fix: ELB configured to use TCP, but no session affinity • Browsers • Issue: IE 6, 7, 8, 9 and Safari 5 do not support WebSocket • Fix: Fallback using Atmosphere, Socket.IO, SockJS #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  212. 212. Production Tips • Load Balancer • Issue: Don’t work with WebSocket, e.g. Amazon ELB • Fix: ELB configured to use TCP, but no session affinity • Browsers • Issue: IE 6, 7, 8, 9 and Safari 5 do not support WebSocket • Fix: Fallback using Atmosphere, Socket.IO, SockJS • Inconsistencies in JSR 356 #Devoxx #WebSocket 69 @arungupta @peterm_kaazing
  213. 213. Atmosphere #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  214. 214. Atmosphere • Java/JavaScript framework #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  215. 215. Atmosphere • Java/JavaScript framework • Portable asynchronous applications #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  216. 216. Atmosphere • Java/JavaScript framework • Portable asynchronous applications • Fallback to long-polling in absence of WebSocket #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  217. 217. Atmosphere • Java/JavaScript framework • Portable asynchronous applications • Fallback to long-polling in absence of WebSocket • Containers: Netty, Jetty, GlassFish, Tomcat, JBoss, WildFly, WebLogic, Resin, WebSphere #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  218. 218. Atmosphere • Java/JavaScript framework • Portable asynchronous applications • Fallback to long-polling in absence of WebSocket • Containers: Netty, Jetty, GlassFish, Tomcat, JBoss, WildFly, WebLogic, Resin, WebSphere • Browsers: Firefox, Chrome, IE (6x+), Opera, Safari, Android #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  219. 219. Atmosphere • Java/JavaScript framework • Portable asynchronous applications • Fallback to long-polling in absence of WebSocket • Containers: Netty, Jetty, GlassFish, Tomcat, JBoss, WildFly, WebLogic, Resin, WebSphere • Browsers: Firefox, Chrome, IE (6x+), Opera, Safari, Android https://github.com/javaee-samples/javaee7-samples/tree/master/websocket/atmosphere-chat #Devoxx #WebSocket 70 @arungupta @peterm_kaazing
  220. 220. Resources • Material: github.com/arun-gupta/nuts-and-bolts-of-websocket #Devoxx #WebSocket 71 @arungupta @peterm_kaazing

×