SlideShare a Scribd company logo
WEB SOCKETS
      CURRENT STATE
   FOR JAVA DEVELOPERS
Web SOCKETS
      CURRENT STATE
   FOR JAVA DEVELOPERS


       PRESENTED
           BY


        VIKTOR
        GAMOV
WEB SOCKETS
                           AGENDA



BIT OF       MEET              WEBSOCKETS       Q&A
HISTORY   THE WEBSOCKETS            IN ACTION   SESSION



                                                 ?
OPTIONS FOR “REALTIME” WEB




  “LEGACY” WEB
      POLLING                           LONG-POLLING                           STEAMING
Browser sends HTTP requests at      Browser sends a request to the
regular intervals and               server and the server keeps the     Browser sends a complete
immediately receives a              request open for a set period       request, but the server sends
response. However, real- time       of time. If a notification is        and maintains an open
data is often not that              received within that period, a      response that is continuously
predictable, making                 response containing the             updated and kept open
unnecessary requests                message is sent to the client. If   indefinitely (or for a set period
inevitable and as a result,         a notification is not received       of time)
many connections are opened         within the set time period, the
and closed needlessly in low-       server sends a response to
message-rate situations             terminate the open request.
WHAT IS WEBSOCKET




“Reducing kilobytes of data to 2 bytes... and reducing latency from 150ms to 50
ms is far more than marginal. In fact, these two factors alone are enough to make
WebSocket seriously interesting...”


                www.ietf.org/mail-archive/web/hybi/current/msg00784.html
WHAT IS WEBSOCKETS?




       WEB SOCKET
STANDARD PROTOCOL              CLIENT-SIDE API         SERVER-SIDE API

 Websocket is a              HTML5 specification       True real-time server
 standardized technology     introduces WebSocket     updates. Expected large
 (described in RFC6455)      client side object. No   penetration in Java
 to support low-overhead     plugin required.         world with upcoming
 bidirectional traffic from                            JavaEE 7 spec and
 your Web browser.                                    JSR-356
WEBSOCKET HANDSHAKE



           To Start full-duplex communication client should send
           UPGRADE request




   1                    2                       3                     4
  SEND                RECEIVE                 CHANGE                LISTEN
UPGRADE             UPGRADE               READYSTATE               MESSAGE
 REQUEST              RESPONSE                TO OPEN                EVENT
DEMO




HANDSHAKE
  DEMO
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WEBSOCKET INTERFACE

[Constructor(DOMString	
  url,	
  optional	
  (DOMString	
  or	
  DOMString[])	
  protocols)]
interface	
  WebSocket	
  :	
  EventTarget	
  {
	
  	
  readonly	
  attribute	
  DOMString	
  url;

	
  	
  //	
  ready	
  state
	
  	
  const	
  unsigned	
  short	
  CONNECTING	
  =	
  0;
	
  	
  const	
  unsigned	
  short	
  OPEN	
  =	
  1;
	
  	
  const	
  unsigned	
  short	
  CLOSING	
  =	
  2;
	
  	
  const	
  unsigned	
  short	
  CLOSED	
  =	
  3;
	
  	
  readonly	
  attribute	
  unsigned	
  short	
  readyState;
	
  	
  readonly	
  attribute	
  unsigned	
  long	
  bufferedAmount;

	
  	
  //	
  networking
	
  	
  [TreatNonCallableAsNull]	
  attribute	
  Function?	
  onopen;
	
  	
  [TreatNonCallableAsNull]	
  attribute	
  Function?	
  onerror;
	
  	
  [TreatNonCallableAsNull]	
  attribute	
  Function?	
  onclose;
	
  	
  readonly	
  attribute	
  DOMString	
  extensions;
	
  	
  readonly	
  attribute	
  DOMString	
  protocol;
	
  	
  void	
  close([Clamp]	
  optional	
  unsigned	
  short	
  code,	
  optional	
  DOMString	
  reason);

	
  	
  //	
  messaging
	
  	
  [TreatNonCallableAsNull]	
  attribute	
  Function?	
  onmessage;
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  attribute	
  DOMString	
  binaryType;
	
  	
  void	
  send(DOMString	
  data);
	
  	
  void	
  send(ArrayBufferView	
  data);
	
  	
  void	
  send(Blob	
  data);
};
CLIENT-SIDE WEBSOCKET API

var	
  ws;
if	
  (window.WebSocket)	
  {
	
  	
  	
  	
  output("WebSocket	
  supported	
  in	
  your	
  browser");
	
  	
  	
  	
  ws	
  =	
  new	
  WebSocket("ws://www.websockets.org");

	
  	
  	
  	
  //	
  Set	
  event	
  handlers.
	
  	
  	
  	
  ws.onopen	
  =	
  function	
  ()	
  {
	
  	
  	
  	
  	
  	
  	
  	
  output("onopen");
	
  	
  	
  	
  };
	
  	
  	
  	
  ws.onmessage	
  =	
  function	
  (e)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  //	
  e.data	
  contains	
  received	
  string.
	
  	
  	
  	
  	
  	
  	
  	
  output("echo	
  from	
  server	
  :	
  "	
  +	
  e.data);
	
  	
  	
  	
  };
	
  	
  	
  	
  ws.onclose	
  =	
  function	
  ()	
  {
	
  	
  	
  	
  	
  	
  	
  	
  output("onclose");
	
  	
  	
  	
  };
	
  	
  	
  	
  ws.onerror	
  =	
  function	
  ()	
  {
	
  	
  	
  	
  	
  	
  	
  	
  output("onerror");
	
  	
  	
  	
  };

}
else	
  {output("WebSocket	
  not	
  supported	
  in	
  your	
  browser");}
JAVA EE 7 SERVER-SIDE API



package	
  org.javaee.glassfishwebsocket;

import	
  org.glassfish.websocket.api.annotations.WebSocket;
import	
  org.glassfish.websocket.api.annotations.WebSocketMessage;

@WebSocket(path	
  =	
  "/echo")
public	
  class	
  EchoBean	
  {
	
  	
  	
  	
  @WebSocketMessage
	
  	
  	
  	
  public	
  String	
  echo(String	
  message)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  System.out.println("#####################	
  Message	
  received");
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  +	
  "	
  (from	
  your	
  server)";
	
  	
  	
  	
  }
}
TOMCAT 7.0.29 SERVER-SIDE API




SHOW
  THE
 CODE
Not enough room for code in this slide ;-)
PROGRAMMING WEBSOCKETS




Client-side frameworks

✦jquery.socket.js
 ✦https://github.com/flowersinthesand/jquery-socket/wiki
✦atmosphere.js
  ✦https://github.com/Atmosphere/atmosphere/wiki/jQuery.atmosphere.js-API
✦socket.io
WEBSOCKET SUPPORT



JAVA-based Web servers with native support.
The WebServer has API for WebSocket

✦Netty 3.3.x
✦Jetty 7.x, 8.x
✦Glassfish 3.1.2
✦Tomcat 7.0.27
WHAT SHOULD WE DO?




   WE CAN DO IT!
WHAT IS ATMOSPHERE
Atmosphere
https://github.com/Atmosphere/atmosphere/


✦portable framework for
 ✦long-polling
 ✦Streaming
 ✦Server-Send Events
 ✦WebSockets
✦can auto select best transport
✦abstracting from actual underlying container
mechanism
THINKING ABOUT USE CASES




               ?
USE CASE
                      OUR CLIENTS



WebSockets really shine with following applications:

✦Live trading/sports ticker
✦Controlling medical equipment over the web
✦Chat applications
✦Multiplayer online games
✦Realtime updating social streams
BUNCH OF USEFUL LINKS



✦http://www.w3.org/TR/websockets/ MUST!
✦http://tools.ietf.org/html/rfc6455 MUST!
✦http://tomcat.apache.org/tomcat-7.0-doc/web-socket-howto.html
✦http://websocket-sdk.java.net/Introduction.html
✦https://github.com/Atmosphere/atmosphere/wiki/Supported-
WebServers-and-Browsers
✦http://autobahn.ws/testsuite
Q AND A




Q&A
Put your questions
CONTACT US




             WWW.FARATASYSTEMS.COM

             INFO@FARATASYSTEMS.COM
FIND ME




            TWITTER                 GITHUB
WWW.TWITTER.COM/GAMUSSA             WWW.GITHUB.COM/GAMUSSA
THANK YOU




THANK YOU
      FOR YOUR ATTENTION




 HTTP://WWW.FARATASYSTEMS.COM
Ad

Recommended

PPTX
WebSockets in JEE 7
Shahzad Badar
 
KEY
The HTML5 WebSocket API
David Lindkvist
 
ZIP
Websocket protocol overview
allenmeng
 
PPTX
vlavrynovych - WebSockets Presentation
Volodymyr Lavrynovych
 
KEY
Pushing the web — WebSockets
Roland M
 
PDF
GWT Web Socket and data serialization
GWTcon
 
PPTX
HTML5 WebSocket Introduction
Marcelo Jabali
 
PPTX
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
Ericom Software
 
PPTX
Ws
Sunghan Kim
 
PPTX
Large scale web socket system with AWS and Web socket
Le Kien Truc
 
PPT
HTML5 WebSocket: The New Network Stack for the Web
Peter Lubbers
 
PDF
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
PDF
Introduction to WebSockets
Gunnar Hillert
 
PPTX
Intro to WebSockets
Gaurav Oberoi
 
PPS
J web socket
Hiroshi Ochi
 
PDF
WebSockets with Spring 4
Sergi Almar i Graupera
 
PPTX
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
Peter Lubbers
 
PPTX
Spring + WebSocket integration
Oleksandr Semenov
 
PDF
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
PPTX
Asynchronous Web Programming with HTML5 WebSockets and Java
James Falkner
 
PDF
Using WebSockets with ColdFusion
cfjedimaster
 
PPTX
Php push notifications
Mohammed Shurrab
 
PDF
Realtime web application with java
JeongHun Byeon
 
PDF
Grizzly 20080925 V2
Eduardo Pelegri-Llopart
 
PPTX
Web sockets in Java
Pance Cavkovski
 
PPTX
WebSocket protocol
Kensaku Komatsu
 
PPTX
Google Chromebook for the Enterprise: Yeah or Meh?
Ericom Software
 
PDF
COMET in Plone
Christian Scholz
 
KEY
Functional UI testing of Adobe Flex RIA
Viktor Gamov
 
PDF
JavaOne 2013: «Java and JavaScript - Shaken, Not Stirred»
Viktor Gamov
 

More Related Content

What's hot (20)

PPTX
Ws
Sunghan Kim
 
PPTX
Large scale web socket system with AWS and Web socket
Le Kien Truc
 
PPT
HTML5 WebSocket: The New Network Stack for the Web
Peter Lubbers
 
PDF
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
PDF
Introduction to WebSockets
Gunnar Hillert
 
PPTX
Intro to WebSockets
Gaurav Oberoi
 
PPS
J web socket
Hiroshi Ochi
 
PDF
WebSockets with Spring 4
Sergi Almar i Graupera
 
PPTX
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
Peter Lubbers
 
PPTX
Spring + WebSocket integration
Oleksandr Semenov
 
PDF
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
PPTX
Asynchronous Web Programming with HTML5 WebSockets and Java
James Falkner
 
PDF
Using WebSockets with ColdFusion
cfjedimaster
 
PPTX
Php push notifications
Mohammed Shurrab
 
PDF
Realtime web application with java
JeongHun Byeon
 
PDF
Grizzly 20080925 V2
Eduardo Pelegri-Llopart
 
PPTX
Web sockets in Java
Pance Cavkovski
 
PPTX
WebSocket protocol
Kensaku Komatsu
 
PPTX
Google Chromebook for the Enterprise: Yeah or Meh?
Ericom Software
 
PDF
COMET in Plone
Christian Scholz
 
Large scale web socket system with AWS and Web socket
Le Kien Truc
 
HTML5 WebSocket: The New Network Stack for the Web
Peter Lubbers
 
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
Introduction to WebSockets
Gunnar Hillert
 
Intro to WebSockets
Gaurav Oberoi
 
J web socket
Hiroshi Ochi
 
WebSockets with Spring 4
Sergi Almar i Graupera
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
Peter Lubbers
 
Spring + WebSocket integration
Oleksandr Semenov
 
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Asynchronous Web Programming with HTML5 WebSockets and Java
James Falkner
 
Using WebSockets with ColdFusion
cfjedimaster
 
Php push notifications
Mohammed Shurrab
 
Realtime web application with java
JeongHun Byeon
 
Grizzly 20080925 V2
Eduardo Pelegri-Llopart
 
Web sockets in Java
Pance Cavkovski
 
WebSocket protocol
Kensaku Komatsu
 
Google Chromebook for the Enterprise: Yeah or Meh?
Ericom Software
 
COMET in Plone
Christian Scholz
 

Viewers also liked (20)

KEY
Functional UI testing of Adobe Flex RIA
Viktor Gamov
 
PDF
JavaOne 2013: «Java and JavaScript - Shaken, Not Stirred»
Viktor Gamov
 
KEY
Testing Flex RIAs for NJ Flex user group
Viktor Gamov
 
PDF
[Jfokus] Riding the Jet Streams
Viktor Gamov
 
PDF
[JokerConf] Верхом на реактивных стримах, 10/13/2016
Viktor Gamov
 
PPTX
[NYJavaSig] Riding the Distributed Streams - Feb 2nd, 2017
Viktor Gamov
 
PPTX
[Codemash] Caching Made "Bootiful"!
Viktor Gamov
 
PDF
[OracleCode - SF] Distributed caching for your next node.js project
Viktor Gamov
 
PDF
[OracleCode SF] In memory analytics with apache spark and hazelcast
Viktor Gamov
 
PPTX
Creating your own private Download Center with Bintray
Baruch Sadogursky
 
PDF
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code SF...
Baruch Sadogursky
 
PPTX
Java 8 Puzzlers [as presented at OSCON 2016]
Baruch Sadogursky
 
PPTX
Spring Data: New approach to persistence
Oleksiy Rezchykov
 
PPTX
Morning at Lohika 2nd anniversary
Taras Matyashovsky
 
PPTX
Confession of an Engineer
Taras Matyashovsky
 
PDF
Couchbase Sydney meetup #1 Couchbase Architecture and Scalability
Karthik Babu Sekar
 
PDF
Patterns and antipatterns in Docker image lifecycle @ DevOpsDays Charlotte 2017
Baruch Sadogursky
 
PPTX
Javaeeconf 2016 how to cook apache kafka with camel and spring boot
Ivan Vasyliev
 
PDF
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Baruch Sadogursky
 
PDF
Patterns and antipatterns in Docker image lifecycle as was presented at Scale...
Baruch Sadogursky
 
Functional UI testing of Adobe Flex RIA
Viktor Gamov
 
JavaOne 2013: «Java and JavaScript - Shaken, Not Stirred»
Viktor Gamov
 
Testing Flex RIAs for NJ Flex user group
Viktor Gamov
 
[Jfokus] Riding the Jet Streams
Viktor Gamov
 
[JokerConf] Верхом на реактивных стримах, 10/13/2016
Viktor Gamov
 
[NYJavaSig] Riding the Distributed Streams - Feb 2nd, 2017
Viktor Gamov
 
[Codemash] Caching Made "Bootiful"!
Viktor Gamov
 
[OracleCode - SF] Distributed caching for your next node.js project
Viktor Gamov
 
[OracleCode SF] In memory analytics with apache spark and hazelcast
Viktor Gamov
 
Creating your own private Download Center with Bintray
Baruch Sadogursky
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code SF...
Baruch Sadogursky
 
Java 8 Puzzlers [as presented at OSCON 2016]
Baruch Sadogursky
 
Spring Data: New approach to persistence
Oleksiy Rezchykov
 
Morning at Lohika 2nd anniversary
Taras Matyashovsky
 
Confession of an Engineer
Taras Matyashovsky
 
Couchbase Sydney meetup #1 Couchbase Architecture and Scalability
Karthik Babu Sekar
 
Patterns and antipatterns in Docker image lifecycle @ DevOpsDays Charlotte 2017
Baruch Sadogursky
 
Javaeeconf 2016 how to cook apache kafka with camel and spring boot
Ivan Vasyliev
 
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Baruch Sadogursky
 
Patterns and antipatterns in Docker image lifecycle as was presented at Scale...
Baruch Sadogursky
 
Ad

Similar to WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers (20)

PPT
Web-Socket
Pankaj Kumar Sharma
 
PPT
JUG louvain websockets
Marc Tritschler
 
PDF
DevCon 5 (July 2013) - WebSockets
Crocodile WebRTC SDK and Cloud Signalling Network
 
PDF
Dev con kolkata 2012 websockets
SANKARSAN BOSE
 
PPTX
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
PDF
Alex carcea, radu macovei a story of how java script joined the big league
Codecamp Romania
 
PPS
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
Innotrade GmbH, jWebSocket.org, Alexander Schulze
 
PPS
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
purans
 
PPTX
Web Sockets are not Just for Web Browsers
cjmyers
 
PDF
WebSockets - Realtime em Mundo Conectado
Bruno Borges
 
PDF
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET Journal
 
PDF
WebSocket
njamnjam
 
PDF
Programming WebSockets - OSCON 2010
sullis
 
PDF
Realizzare applicazioni Web con WebSocket, by Simone Bordet
Codemotion
 
ODP
Building Websocket Applications with GlassFish and Grizzly
Justin Lee
 
PPTX
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
PPTX
Codecamp Iasi-26 nov 2011 - Html 5 WebSockets
Florin Cardasim
 
PPTX
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
PPTX
Messaging for Real-time WebApps
Tiju John
 
PPTX
Fight empire-html5
Bhakti Mehta
 
JUG louvain websockets
Marc Tritschler
 
DevCon 5 (July 2013) - WebSockets
Crocodile WebRTC SDK and Cloud Signalling Network
 
Dev con kolkata 2012 websockets
SANKARSAN BOSE
 
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
Alex carcea, radu macovei a story of how java script joined the big league
Codecamp Romania
 
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
Innotrade GmbH, jWebSocket.org, Alexander Schulze
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
purans
 
Web Sockets are not Just for Web Browsers
cjmyers
 
WebSockets - Realtime em Mundo Conectado
Bruno Borges
 
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET Journal
 
WebSocket
njamnjam
 
Programming WebSockets - OSCON 2010
sullis
 
Realizzare applicazioni Web con WebSocket, by Simone Bordet
Codemotion
 
Building Websocket Applications with GlassFish and Grizzly
Justin Lee
 
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
Codecamp Iasi-26 nov 2011 - Html 5 WebSockets
Florin Cardasim
 
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
Messaging for Real-time WebApps
Tiju John
 
Fight empire-html5
Bhakti Mehta
 
Ad

More from Viktor Gamov (7)

PDF
[DataSciCon] Divide, distribute and conquer stream v. batch
Viktor Gamov
 
PDF
[Philly JUG] Divide, Distribute and Conquer: Stream v. Batch
Viktor Gamov
 
PDF
Testing containers with TestContainers @ AJUG 7/18/2017
Viktor Gamov
 
PDF
Distributed caching for your next node.js project cf summit - 06-15-2017
Viktor Gamov
 
PDF
[Philly ETE] Java Puzzlers NG
Viktor Gamov
 
PDF
Распределяй и властвуй — 2: Потоки данных наносят ответный удар
Viktor Gamov
 
PDF
[JBreak] Блеск И Нищета Распределенных Стримов - 04-04-2017
Viktor Gamov
 
[DataSciCon] Divide, distribute and conquer stream v. batch
Viktor Gamov
 
[Philly JUG] Divide, Distribute and Conquer: Stream v. Batch
Viktor Gamov
 
Testing containers with TestContainers @ AJUG 7/18/2017
Viktor Gamov
 
Distributed caching for your next node.js project cf summit - 06-15-2017
Viktor Gamov
 
[Philly ETE] Java Puzzlers NG
Viktor Gamov
 
Распределяй и властвуй — 2: Потоки данных наносят ответный удар
Viktor Gamov
 
[JBreak] Блеск И Нищета Распределенных Стримов - 04-04-2017
Viktor Gamov
 

Recently uploaded (20)

PDF
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
 
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
PDF
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
PDF
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
PDF
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
PDF
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PPTX
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
PDF
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
PPTX
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
PPTX
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
PDF
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
PDF
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
PDF
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
ninefyi
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 

WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers

  • 1. WEB SOCKETS CURRENT STATE FOR JAVA DEVELOPERS
  • 2. Web SOCKETS CURRENT STATE FOR JAVA DEVELOPERS PRESENTED BY VIKTOR GAMOV
  • 3. WEB SOCKETS AGENDA BIT OF MEET WEBSOCKETS Q&A HISTORY THE WEBSOCKETS IN ACTION SESSION ?
  • 4. OPTIONS FOR “REALTIME” WEB “LEGACY” WEB POLLING LONG-POLLING STEAMING Browser sends HTTP requests at Browser sends a request to the regular intervals and server and the server keeps the Browser sends a complete immediately receives a request open for a set period request, but the server sends response. However, real- time of time. If a notification is and maintains an open data is often not that received within that period, a response that is continuously predictable, making response containing the updated and kept open unnecessary requests message is sent to the client. If indefinitely (or for a set period inevitable and as a result, a notification is not received of time) many connections are opened within the set time period, the and closed needlessly in low- server sends a response to message-rate situations terminate the open request.
  • 5. WHAT IS WEBSOCKET “Reducing kilobytes of data to 2 bytes... and reducing latency from 150ms to 50 ms is far more than marginal. In fact, these two factors alone are enough to make WebSocket seriously interesting...” www.ietf.org/mail-archive/web/hybi/current/msg00784.html
  • 6. WHAT IS WEBSOCKETS? WEB SOCKET STANDARD PROTOCOL CLIENT-SIDE API SERVER-SIDE API Websocket is a HTML5 specification True real-time server standardized technology introduces WebSocket updates. Expected large (described in RFC6455) client side object. No penetration in Java to support low-overhead plugin required. world with upcoming bidirectional traffic from JavaEE 7 spec and your Web browser. JSR-356
  • 7. WEBSOCKET HANDSHAKE To Start full-duplex communication client should send UPGRADE request 1 2 3 4 SEND RECEIVE CHANGE LISTEN UPGRADE UPGRADE READYSTATE MESSAGE REQUEST RESPONSE TO OPEN EVENT
  • 10. WEBSOCKET INTERFACE [Constructor(DOMString  url,  optional  (DOMString  or  DOMString[])  protocols)] interface  WebSocket  :  EventTarget  {    readonly  attribute  DOMString  url;    //  ready  state    const  unsigned  short  CONNECTING  =  0;    const  unsigned  short  OPEN  =  1;    const  unsigned  short  CLOSING  =  2;    const  unsigned  short  CLOSED  =  3;    readonly  attribute  unsigned  short  readyState;    readonly  attribute  unsigned  long  bufferedAmount;    //  networking    [TreatNonCallableAsNull]  attribute  Function?  onopen;    [TreatNonCallableAsNull]  attribute  Function?  onerror;    [TreatNonCallableAsNull]  attribute  Function?  onclose;    readonly  attribute  DOMString  extensions;    readonly  attribute  DOMString  protocol;    void  close([Clamp]  optional  unsigned  short  code,  optional  DOMString  reason);    //  messaging    [TreatNonCallableAsNull]  attribute  Function?  onmessage;                      attribute  DOMString  binaryType;    void  send(DOMString  data);    void  send(ArrayBufferView  data);    void  send(Blob  data); };
  • 11. CLIENT-SIDE WEBSOCKET API var  ws; if  (window.WebSocket)  {        output("WebSocket  supported  in  your  browser");        ws  =  new  WebSocket("ws://www.websockets.org");        //  Set  event  handlers.        ws.onopen  =  function  ()  {                output("onopen");        };        ws.onmessage  =  function  (e)  {                //  e.data  contains  received  string.                output("echo  from  server  :  "  +  e.data);        };        ws.onclose  =  function  ()  {                output("onclose");        };        ws.onerror  =  function  ()  {                output("onerror");        }; } else  {output("WebSocket  not  supported  in  your  browser");}
  • 12. JAVA EE 7 SERVER-SIDE API package  org.javaee.glassfishwebsocket; import  org.glassfish.websocket.api.annotations.WebSocket; import  org.glassfish.websocket.api.annotations.WebSocketMessage; @WebSocket(path  =  "/echo") public  class  EchoBean  {        @WebSocketMessage        public  String  echo(String  message)  {                System.out.println("#####################  Message  received");                return  message  +  "  (from  your  server)";        } }
  • 13. TOMCAT 7.0.29 SERVER-SIDE API SHOW THE CODE Not enough room for code in this slide ;-)
  • 14. PROGRAMMING WEBSOCKETS Client-side frameworks ✦jquery.socket.js ✦https://github.com/flowersinthesand/jquery-socket/wiki ✦atmosphere.js ✦https://github.com/Atmosphere/atmosphere/wiki/jQuery.atmosphere.js-API ✦socket.io
  • 15. WEBSOCKET SUPPORT JAVA-based Web servers with native support. The WebServer has API for WebSocket ✦Netty 3.3.x ✦Jetty 7.x, 8.x ✦Glassfish 3.1.2 ✦Tomcat 7.0.27
  • 16. WHAT SHOULD WE DO? WE CAN DO IT!
  • 17. WHAT IS ATMOSPHERE Atmosphere https://github.com/Atmosphere/atmosphere/ ✦portable framework for ✦long-polling ✦Streaming ✦Server-Send Events ✦WebSockets ✦can auto select best transport ✦abstracting from actual underlying container mechanism
  • 19. USE CASE OUR CLIENTS WebSockets really shine with following applications: ✦Live trading/sports ticker ✦Controlling medical equipment over the web ✦Chat applications ✦Multiplayer online games ✦Realtime updating social streams
  • 20. BUNCH OF USEFUL LINKS ✦http://www.w3.org/TR/websockets/ MUST! ✦http://tools.ietf.org/html/rfc6455 MUST! ✦http://tomcat.apache.org/tomcat-7.0-doc/web-socket-howto.html ✦http://websocket-sdk.java.net/Introduction.html ✦https://github.com/Atmosphere/atmosphere/wiki/Supported- WebServers-and-Browsers ✦http://autobahn.ws/testsuite
  • 21. Q AND A Q&A Put your questions
  • 22. CONTACT US WWW.FARATASYSTEMS.COM [email protected]
  • 23. FIND ME TWITTER GITHUB WWW.TWITTER.COM/GAMUSSA WWW.GITHUB.COM/GAMUSSA
  • 24. THANK YOU THANK YOU FOR YOUR ATTENTION HTTP://WWW.FARATASYSTEMS.COM