SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Java User Group Louvain-La-Neuve 
9/10/2014 – EPHEC LLN 
Rudy Vissers 
Coding Java WebSocket Applications 
Using the JSR 356 API
Introduction 
● HTTP(Hypertext Transfer Protocol) is a 
stateless request-response protocol. 
● This simple design of the HTTP protocol 
makes it very scalable but inefficient and 
unsuitable for highly interactive real-time web 
applications : Chat applications, Multiplayer 
games, etc. 
● HTTP was designed for document sharing 
and not for building today’s highly 
interactive web applications. 
● HTTP is bit chatty in nature,
Introduction cont. 
● Before the HTTP 1.1 version, every request 
made to the server resulted in a new 
connection. 
● This was improved in HTTP 1.1 with the 
introduction of HTTP persistence connections. 
● Persistent connections allowed web browsers 
to reuse the same connection for fetching 
images, scripts, etc.
Introduction cont. 
● HTTP was designed to be half-duplex which 
means it allows transmission of data in just one 
direction at a time. 
● A Walkie-talkie is an example of a half 
duplex device because only one person can 
speak at a time. 
● Developers have created some workarounds or 
hacks to overcome this HTTP shortcoming : 
polling, long polling, and streaming.
Introduction cont. 
● With polling, the client makes synchronous 
calls to get information from the server. Do you 
have something for me ? 
● If the server has new information available it will 
send back data in the response. 
● Otherwise, no information will be sent to the 
client and the client will again make a new 
connection after sometime. 
● This is very inefficient but a very simple way 
to achieve real-time behavior.
What is a WebSocket? 
● A WebSocket is asynchronous, bidirectional, 
full-duplex messaging implementation over a 
single TCP connection. 
● WebSockets are not a HTTP connection , but 
use HTTP to bootstrap a WebSocket 
connection. 
● A full-duplex system allows communication in 
both directions simultaneously. 
● Telephones lines are an example of a full-duplex 
device, since they allow both callers to 
speak and be heard at the same time.
What is a WebSocket? cont. 
● RFC 6455 : 
The WebSocket Protocol : 
http://tools.ietf.org/html/rfc6455 
● JSR 356 : 
Java API for WebSocket : 
https://jcp.org/en/jsr/detail?id=356 
● WebSocket JavaScript API : 
http://www.w3.org/TR/2011/WD-websockets- 
20110419
Browsers : can I use ? 
● WebSockets are supported by all the latest 
browsers.
How Does a WebSocket Work? 
● Every WebSocket connection begins its life as 
an HTTP request. 
● The HTTP request is much like another 
request, except that it has an Upgrade header. 
● The Upgrade header indicates that a client 
would like to upgrade the connection to 
different protocol(s). 
● For WebSockets it will upgrade to the 
WebSocket protocol. 
● The WebSocket connection is established by 
upgrading from HTTP protocol to the
WebSocket is more complex than 
HTTP 
● You can establish an HTTP connection with a 
telnet client, telnet localhost 80 :-) 
but you probably cannot do the same with WS. 
● Even if you ignored the handshake 
requirements (which include the use of the 
SHA1 hash function), you would then be unable 
to properly mask and frame the data to be sent 
and the server would close the connection.
WebSocket is more complex than 
HTTP cont. 
● WebSocket connections are intended to be 
more persistent than HTTP connections. 
● If you only want to receive an update every 30 
minutes, you will want to go with HTTP. 
● If you want to receive updates every second, a 
WebSocket might be a better option, because 
establishing an HTTP connection takes a lot 
of time.
WebSockets simplify real-time 
application architectures 
● For these kind of applications WebSockets are 
more efficient and performant than other 
workarounds like polling. 
● They require less bandwidth and reduce 
latency. 
● WebSockets do not require headers to send 
messages between peers. 
● This considerably lowers the required 
bandwidth.
WebSocket Use Cases 
● Chat applications 
● Multiplayer games 
● Stock trading or financial applications 
● Collaborative document editing 
● Social networking applications
Java APIs 
● JSR 356, Java API for WebSocket, specifies 
Java API that developers can use to integrate 
WebSockets into their applications both on the 
server side as well as on the Java client side. 
● JSR 356 is part of the upcoming Java EE 7 
standard. 
● This means all Java EE 7 compliant application 
servers will have an implementation of the 
WebSocket protocol that adheres to the JSR 
356 standard. 
● Developers can also use JSR 356 outside Java
Java APIs cont. 
● A Java client can use JSR 356 compliant client 
implementation to connect to a WebSocket 
server (Tyrus). 
● For web clients, developers can use 
WebSocket JavaScript API to communicate 
with WebSocket server. 
● The difference between a WebSocket client 
and a WebSocket server lies only in the means 
by which the two are connected. 
● A WebSocket client is a WebSocket endpoint 
that initiates a connection to a peer.
● Time to code !

Weitere ähnliche Inhalte

Was ist angesagt?

PMTA Success Story - J2 Martech
PMTA Success Story - J2 MartechPMTA Success Story - J2 Martech
PMTA Success Story - J2 MartechSparkPost
 
Zing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectZing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectChau Thanh
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? Sigma Software
 
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownDebugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownAspen Mesh
 
Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Ulf Lilleengen
 
Web performance across the HTTP to HTTPS transition
Web performance across the HTTP to HTTPS transitionWeb performance across the HTTP to HTTPS transition
Web performance across the HTTP to HTTPS transitionseanwalbran
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web DevelopmentGLC Networks
 
Systems management - UltraESB
Systems management - UltraESBSystems management - UltraESB
Systems management - UltraESBAdroitLogic
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performaceTuyển Đoàn
 
Connection load balancing with mikrotik [workshop]
Connection load balancing with mikrotik [workshop]Connection load balancing with mikrotik [workshop]
Connection load balancing with mikrotik [workshop]Achmad Mardiansyah
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
System Configuration for UltraESB
System Configuration for UltraESBSystem Configuration for UltraESB
System Configuration for UltraESBAdroitLogic
 

Was ist angesagt? (20)

gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
PMTA Success Story - J2 Martech
PMTA Success Story - J2 MartechPMTA Success Story - J2 Martech
PMTA Success Story - J2 Martech
 
Web Sockets - HTML5
Web Sockets - HTML5Web Sockets - HTML5
Web Sockets - HTML5
 
HTTP/2
HTTP/2HTTP/2
HTTP/2
 
Zing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectZing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat Architect
 
Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
Internet protocol
Internet protocolInternet protocol
Internet protocol
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know?
 
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownDebugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
 
Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017
 
Web performance across the HTTP to HTTPS transition
Web performance across the HTTP to HTTPS transitionWeb performance across the HTTP to HTTPS transition
Web performance across the HTTP to HTTPS transition
 
Http 2
Http 2Http 2
Http 2
 
Intro to WebSockets
Intro to WebSocketsIntro to WebSockets
Intro to WebSockets
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web Development
 
Systems management - UltraESB
Systems management - UltraESBSystems management - UltraESB
Systems management - UltraESB
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performace
 
Connection load balancing with mikrotik [workshop]
Connection load balancing with mikrotik [workshop]Connection load balancing with mikrotik [workshop]
Connection load balancing with mikrotik [workshop]
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
System Configuration for UltraESB
System Configuration for UltraESBSystem Configuration for UltraESB
System Configuration for UltraESB
 

Ähnlich wie JUG louvain websockets

Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsNaresh Chintalcheru
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stackRed Hat
 
Understanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxUnderstanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxKnoldus Inc.
 
Understanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideUnderstanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideKnoldus Inc.
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...Edward Burns
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkFabio Tiriticco
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientKnoldus Inc.
 
Decoding real time web communication
Decoding real time web communicationDecoding real time web communication
Decoding real time web communicationAMiT JAiN
 
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time CommunicationIRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time CommunicationIRJET Journal
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceRick Hightower
 
Next generation web protocols
Next generation web protocolsNext generation web protocols
Next generation web protocolsDaniel Austin
 

Ähnlich wie JUG louvain websockets (20)

Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
 
Understanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxUnderstanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptx
 
Understanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideUnderstanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive Guide
 
ClientServer Websocket.pptx
ClientServer Websocket.pptxClientServer Websocket.pptx
ClientServer Websocket.pptx
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
Web socket with php v2
Web socket with php v2Web socket with php v2
Web socket with php v2
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
KrakenD API Gateway
KrakenD API GatewayKrakenD API Gateway
KrakenD API Gateway
 
Monkey Server
Monkey ServerMonkey Server
Monkey Server
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
WebRCT
WebRCTWebRCT
WebRCT
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP Client
 
Decoding real time web communication
Decoding real time web communicationDecoding real time web communication
Decoding real time web communication
 
Real time web apps
Real time web appsReal time web apps
Real time web apps
 
WebRTC Seminar Report
WebRTC  Seminar ReportWebRTC  Seminar Report
WebRTC Seminar Report
 
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time CommunicationIRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST Microservice
 
Next generation web protocols
Next generation web protocolsNext generation web protocols
Next generation web protocols
 

Kürzlich hochgeladen

20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查ydyuyu
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查ydyuyu
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样ayvbos
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsMonica Sydney
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasDigicorns Technologies
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoilmeghakumariji156
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制pxcywzqs
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtrahman018755
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Roommeghakumariji156
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 

Kürzlich hochgeladen (20)

20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 

JUG louvain websockets

  • 1. Java User Group Louvain-La-Neuve 9/10/2014 – EPHEC LLN Rudy Vissers Coding Java WebSocket Applications Using the JSR 356 API
  • 2. Introduction ● HTTP(Hypertext Transfer Protocol) is a stateless request-response protocol. ● This simple design of the HTTP protocol makes it very scalable but inefficient and unsuitable for highly interactive real-time web applications : Chat applications, Multiplayer games, etc. ● HTTP was designed for document sharing and not for building today’s highly interactive web applications. ● HTTP is bit chatty in nature,
  • 3. Introduction cont. ● Before the HTTP 1.1 version, every request made to the server resulted in a new connection. ● This was improved in HTTP 1.1 with the introduction of HTTP persistence connections. ● Persistent connections allowed web browsers to reuse the same connection for fetching images, scripts, etc.
  • 4. Introduction cont. ● HTTP was designed to be half-duplex which means it allows transmission of data in just one direction at a time. ● A Walkie-talkie is an example of a half duplex device because only one person can speak at a time. ● Developers have created some workarounds or hacks to overcome this HTTP shortcoming : polling, long polling, and streaming.
  • 5. Introduction cont. ● With polling, the client makes synchronous calls to get information from the server. Do you have something for me ? ● If the server has new information available it will send back data in the response. ● Otherwise, no information will be sent to the client and the client will again make a new connection after sometime. ● This is very inefficient but a very simple way to achieve real-time behavior.
  • 6. What is a WebSocket? ● A WebSocket is asynchronous, bidirectional, full-duplex messaging implementation over a single TCP connection. ● WebSockets are not a HTTP connection , but use HTTP to bootstrap a WebSocket connection. ● A full-duplex system allows communication in both directions simultaneously. ● Telephones lines are an example of a full-duplex device, since they allow both callers to speak and be heard at the same time.
  • 7. What is a WebSocket? cont. ● RFC 6455 : The WebSocket Protocol : http://tools.ietf.org/html/rfc6455 ● JSR 356 : Java API for WebSocket : https://jcp.org/en/jsr/detail?id=356 ● WebSocket JavaScript API : http://www.w3.org/TR/2011/WD-websockets- 20110419
  • 8. Browsers : can I use ? ● WebSockets are supported by all the latest browsers.
  • 9. How Does a WebSocket Work? ● Every WebSocket connection begins its life as an HTTP request. ● The HTTP request is much like another request, except that it has an Upgrade header. ● The Upgrade header indicates that a client would like to upgrade the connection to different protocol(s). ● For WebSockets it will upgrade to the WebSocket protocol. ● The WebSocket connection is established by upgrading from HTTP protocol to the
  • 10. WebSocket is more complex than HTTP ● You can establish an HTTP connection with a telnet client, telnet localhost 80 :-) but you probably cannot do the same with WS. ● Even if you ignored the handshake requirements (which include the use of the SHA1 hash function), you would then be unable to properly mask and frame the data to be sent and the server would close the connection.
  • 11. WebSocket is more complex than HTTP cont. ● WebSocket connections are intended to be more persistent than HTTP connections. ● If you only want to receive an update every 30 minutes, you will want to go with HTTP. ● If you want to receive updates every second, a WebSocket might be a better option, because establishing an HTTP connection takes a lot of time.
  • 12. WebSockets simplify real-time application architectures ● For these kind of applications WebSockets are more efficient and performant than other workarounds like polling. ● They require less bandwidth and reduce latency. ● WebSockets do not require headers to send messages between peers. ● This considerably lowers the required bandwidth.
  • 13. WebSocket Use Cases ● Chat applications ● Multiplayer games ● Stock trading or financial applications ● Collaborative document editing ● Social networking applications
  • 14. Java APIs ● JSR 356, Java API for WebSocket, specifies Java API that developers can use to integrate WebSockets into their applications both on the server side as well as on the Java client side. ● JSR 356 is part of the upcoming Java EE 7 standard. ● This means all Java EE 7 compliant application servers will have an implementation of the WebSocket protocol that adheres to the JSR 356 standard. ● Developers can also use JSR 356 outside Java
  • 15. Java APIs cont. ● A Java client can use JSR 356 compliant client implementation to connect to a WebSocket server (Tyrus). ● For web clients, developers can use WebSocket JavaScript API to communicate with WebSocket server. ● The difference between a WebSocket client and a WebSocket server lies only in the means by which the two are connected. ● A WebSocket client is a WebSocket endpoint that initiates a connection to a peer.
  • 16. ● Time to code !