Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Matthias Wessendorf on WebSocket
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Enterprise Java User Group Austria
May 19, 2011
Technology
78
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Matthias Wessendorf on WebSocket
Enterprise Java User Group Austria
May 19, 2011
More Decks by Enterprise Java User Group Austria
See All by Enterprise Java User Group Austria
Gerrit Grunwald on What the CRaC... SUPERFAST JVM STARTUP
ejug
2
210
Spring Framework 5.2 - Core Container Revisited
ejug
0
190
Andreas Caternberg on Jenkins Pipelines
ejug
1
810
Martin Ahrer on Continuous Delivery Infrastructure With Docker
ejug
0
170
Dirk Mahler on Software Analyse mit jQAssistant & Neo4j
ejug
1
320
Christoph Strobl on Spring Data & Hypermedia
ejug
0
170
Stefan Armbruster on Graph Modelling Antipatterns
ejug
1
140
Stefan Armbruster on Introduction into Neo4J
ejug
1
110
Michael Nitschinger on Building a reactive Couchbase driver for the JVM
ejug
0
160
Other Decks in Technology
See All in Technology
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
130
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
160
【試作】IoT x AIエージェント
happysamurai294
0
120
多摩川(.dev)ランニング入門 / Tamagawa.dev#3
fujiwara3
3
330
Jetpack Compose で挑む新聞紙面UI ─ 複合ジェスチャー・ポリゴン記事領域・適応的ページ構成という3つの壁/droidkaigi2026
nikkei_engineer_recruiting
0
190
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
280
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
140
作り直せるコードは迅速に 作り直せないDBは慎重に - AI時代のプロダクトエンジニアが「判断の不可逆性」で開発速度を変える話
kinosuke01
0
190
[RSJ26] Building a VLA Model Based on Self-Distilled Classification
keio_smilab
PRO
0
190
Azure App Service / Container Apps の組み込み認証
kuniteru
0
190
いま、生成AIにKaggleをどこまで 任せられるか — ROGIIコンペでの進め方とTips
k951286
2
1.3k
データエンジニアの困りごとをDevinと一緒に解消する
10xinc
2
790
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
490
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Accessibility Awareness
sabderemane
1
200
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
510
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
390
Crafting Experiences
bethany
1
280
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Transcript
29.06.11 1 1! Copyright © 2011 – Kaazing Corporation 2!
Copyright © 2011 – Kaazing Corporation Think BIG, Really BIG! Building next-generation Web Apps with WebSocket and HTML5 3! Copyright © 2011 – Kaazing Corporation Matthias Weßendorf • Kaazing Corporation (http://kaazing.com) • Kaazing WebSocket Gateway • Apache Software Foundation • Speaker, Author, Blogger: http://matthiaswessendorf.wordpress.com • Twitter: @mwessendorf 4! Copyright © 2011 – Kaazing Corporation • HTML 5 • Overview • Real Time (Web) • Introduction • WebSocket • Introduction • Handshake and Client API • Remix! • WebSocket and other (HTML5) APIs Agenda 5! Copyright © 2011 – Kaazing Corporation • HTML 5 • Overview • Real Time (Web) • Introduction • WebSocket • Introduction • Handshake and Client API • Remix! • WebSocket and other (HTML5) APIs Agenda 6! Copyright © 2011 – Kaazing Corporation • HTML5 is brand new • Indeed, it isn’t finished yet! • History • first draft: 1993 • HTML 4.0.1: 1999 • 2004: “Bringing the web to the next level” • Web 2.0 started around this time • HTML5 (by WHATWG) • 2006: W3C got involved – first HTML5 draft in 2008 • 2014: W3C recommendation ! • HTML5 is “done” by: • WHATWG • W3C • IETF HTML5 – Facts!
29.06.11 2 7! Copyright © 2011 – Kaazing Corporation Moments
in HTML! HTML5 8! Copyright © 2011 – Kaazing Corporation Moments in HTML! HTML5 9! Copyright © 2011 – Kaazing Corporation Moments in HTML! HTML5 10! Copyright © 2011 – Kaazing Corporation • Use <header>, not <div id=“header”>* • User is king: • id=myDiv VS id=“myDiv” VS ID=myDiv • Simplification • Simple is better. Simplify where possible • Doctype: <!DOCTYPE html> • Accessibility • No Browser Plugins! • Plugins can be blocked ! • Check you phone!! HTML5: it’s all about the user 11! Copyright © 2011 – Kaazing Corporation • Canvas • Geolocation • Server-Sent events • SVG • WebSocket • WebWorker • XHR Level2 • Web Storage • ! HTML5 – A few APIs* 12! Copyright © 2011 – Kaazing Corporation • Simple Demo! • Advanced Demo: (thanks to Gerrit Grunwald (@hansolo_)) Canvas – Was kann das?
29.06.11 3 13! Copyright © 2011 – Kaazing Corporation •
Mashup = Geolocation + Google Maps Geolocation + Google Maps 14! Copyright © 2011 – Kaazing Corporation • HTML 5 • Overview • Real Time (Web) • Introduction • WebSocket • Introduction • Handshake and Client API • Remix! • WebSocket and other (HTML5) APIs Agenda 15! Copyright © 2011 – Kaazing Corporation • Every application has a hook! • Collaborative tooling • Share / edit documents • chat • Gaming (web based games) • Streaming data (! football / sports) • Trading Systems (! auctions) • Financial apps (! market data) • Social Network app • (Web-based) Support Systems • Monitoring (! server console) What is your use-case? Real Time (Web) 16! Copyright © 2011 – Kaazing Corporation • Collaborative Tooling: Drop the built-in latency Push the data...! 17! Copyright © 2011 – Kaazing Corporation Think different ! 18! Copyright © 2011 – Kaazing Corporation Think different!
29.06.11 4 19! Copyright © 2011 – Kaazing Corporation Challenge!
“If we were not restricted by the traditional limitations of HTTP, what type of Web applications would we build?” 20! Copyright © 2011 – Kaazing Corporation • Enter HTML5 WebSocket! Agenda 21! Copyright © 2011 – Kaazing Corporation ! is a bi-directional AND full-duplex communication STANDARD for next-generation web applications (“TCP for the web”) WebSocket ! 22! Copyright © 2011 – Kaazing Corporation Build the future! ! and HTML5 APIs 23! Copyright © 2011 – Kaazing Corporation • Enables web pages to communicate (in full-duplex mode) with a remote host • Traverses firewalls, proxies, and routers seamlessly • Leverages Cross-Origin Resource Sharing (CORS) • Shares port with existing HTTP content (80, 443) • Work with existing Authentication and Authorization frameworks (e.g. Kerberos) • Extend any TCP/UDP based protocol!!! • AMQP • XMPP/STOMP/JMS • VNC • ! WebSocket is full-duplex! 24! Copyright © 2011 – Kaazing Corporation • Canvas and WebSocket Demo: HTML5 mix!
29.06.11 5 25! Copyright © 2011 – Kaazing Corporation HTTP
is Half Duplex 26! Copyright © 2011 – Kaazing Corporation Half Duplex Communication is Primitive 27! Copyright © 2011 – Kaazing Corporation • What are some common names for Ajax Polling implementations? Question for the Audience! 28! Copyright © 2011 – Kaazing Corporation WebSocket HTTP Header Overhead 29! Copyright © 2011 – Kaazing Corporation Confidential WebSockets delivers substantially higher performance with significantly less bandwidth !"###$ !#"###$ !##"###$ %&'()*+,-&.$$+/(0-%*++&1$ 2$34$.5*&0+-$ HTTP traffic* WebSockets Traffic* Google 788 bytes, plus 1 byte 1 byte, plus 1 byte Yahoo 1737 bytes, plus 1 byte 1 byte, plus 1 byte * Header information for each character entered into search bar HTTP WebSockets HTTP vs. WebSockets 30! Copyright © 2011 – Kaazing Corporation From Complexity! (spell it with the letters C,O,M,E,T!) ! to simplicity! Enter WebSocket!
29.06.11 6 31! Copyright © 2011 – Kaazing Corporation •
Client API (W3C) • (simple) JavaScript API • Network Protocol (IETF) • Under development • draft-hixie-thewebsocketprotocol-76 • ... • draft-ietf-hybi-thewebsocketprotocol-07* WebSocket Standard 32! Copyright © 2011 – Kaazing Corporation WS Protocol / Handshake !"#$%&'()$*##+%,-,$ *./)0$/12312-14(5671-&.5$ 8692(:10$websocket$ ;.<<1&=.<0$8692(:1$ >1&?WebSocket?@1A0$:!'7B*C'DEF/G>FHDIJKGLMM$ >1&?WebSocket?N2O9O<0$'P60%%14(5671-&.5$ >1&?WebSocket?+2.).&.70$&'()Q$/H612&'()$ >1&?WebSocket?R12/O.<0$S$ $ $ $ $*##+%,-,$,T,$>UO)&'O<9$+2.).&.7/$ $ $ $8692(:10$websocket$ $ $ $;.<<1&=.<0$8692(:1$ $ $ $>1&?WebSocket?V&&16)0$/W6+XYFO#4(LZ[\!]]'G^D@_4N.M$ $ $ $>1&?WebSocket?+2.).&.70$&'()$ 33! Copyright © 2011 – Kaazing Corporation • Connection established by upgrading from the HTTP protocol to the WebSocket protocol using the same TCP connection • Once upgraded, WebSocket data frames can be sent back and forth between the client and the server in full-duplex mode • Frames can be sent full-duplex, in both directions at the same time • Each frame of data: • Starts with a 0x00 byte and ends with a 0xFF byte • Contains UTF-8 data in between: \0x00Hello, WebSocket\0xff • There is no defined maximum size, but JavaScript does not allow >4GB of data) WebSocket Traffic 34! Copyright © 2011 – Kaazing Corporation WebSocket Less Overhead... A lot less!!! \0x00Hello, WebSocket\0xff 35! Copyright © 2011 – Kaazing Corporation WebSocket Client API // Create new WebSocket var mySocket = new WebSocket("ws://echo.websockets.org"); // Attach listeners mySocket.onmessage = function(evt) { doSomeFancyDhtml(evt.data); }; mySocket.onopen = function(evt) {...}; mySocket.onclose = function(evt) {...}; mySocket.onerror = function(evt) {...}; JavaScript 36! Copyright © 2011 – Kaazing Corporation WebSocket Client API // Send data... mySocket.send(”HTML5 WebSocket rocks! "); // Close WebSocket mySocket.close(); JavaScript
29.06.11 7 37! Copyright © 2011 – Kaazing Corporation •
UDP broadcaster meets WebSocket! DEMO 38! Copyright © 2011 – Kaazing Corporation • Browsers: • Firefox 4 (will be enabled in FF5) • Chrome/Chromium • Safari 5 & iOS4 • IE (there is a plugin) • To test support visit: http://websocket.org • Servers: • Kaazing WebSocket Gateway • Node.js • mod_pywebsocket • Netty • Resin WebSocket Support 39! Copyright © 2011 – Kaazing Corporation • It is NOT just a better Ajax or XHR, nor was it designed to be! • WebSocket was NOT designed to be a one- size-fits-all replacement for HTTP! WebSocket Misconception 40! Copyright © 2011 – Kaazing Corporation • When you build Desktop applications (client server solutions) do you develop your application using raw TCP sockets? • Or, are you using higher level protocols and APIs, such as XMPP, JMS, JDBC? WebSocket Misconception 41! Copyright © 2011 – Kaazing Corporation You should think of WebSocket the same way: • Extend client-server protocols to the Web • XMPP, Jabber • Pub/Sub (Stomp/AMQP) • Gaming protocols • Any TCP-based protocol Beyond WebSockets 42! Copyright © 2011 – Kaazing Corporation Using Stomp/JMS API ... var stompConnectionFactory = new StompConnectionFactory( "ws://localhost:8000/jms"); var connectionFuture = stompConnectionFactory.createConnection (function () { if (!connectionFuture.exception) { connection = connectionFuture.getValue(); connection.setExceptionListener(handleException); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); topic = session.createTopic("/topic/destination"); // creating some consumers! var consumer1 = session.createConsumer(topic); consumer1.setMessageListener(handleMessageCallback); connection.start(someCallback); } .... }); JavaScript
29.06.11 8 43! Copyright © 2011 – Kaazing Corporation Using
Stomp/JMS API function handleMessageCallack(message) { // did Apache ActiveMQ send us a JMS TextMessage? if (message instanceof TextMessage) { var body = message.getText(); // do more stuff... } } JavaScript 44! Copyright © 2011 – Kaazing Corporation WebSocket Architecture 45! Copyright © 2011 – Kaazing Corporation • HTML 5 • Overview • Real Time (Web) • Introduction • WebSocket • Introduction • Handshake and Client API • Remix! • WebSocket and other (HTML5) APIs Agenda 46! Copyright © 2011 – Kaazing Corporation • A real-time tracker application • Logistics • Sports (running) • Using Geolocation API and WebSocket Geolocation and WebSocket 47! Copyright © 2011 – Kaazing Corporation Geolocation and WebSocket // register ‘update’ handler geolocation.watchPosition(updateLocation, handleError); function updateLocation(pos) { // get the current position var lat = pos.coords.latitude; var lon = pos.coords.longitude; var data = JSON.stringify([userId, lat, long]); // tell the server where I am ... myWebSocket.send(data); } // onmessage handler can be used to observe other peers JavaScript 48! Copyright © 2011 – Kaazing Corporation • Stomp/JMS over WebSocket • Apache ActiveMQ (or any JMS broker, e.g. Tibco EMS) • Stock Ticker: • HTML Table • DHTML • You can use jQuery, Dojo, etc!. DHTML and WebSocket
29.06.11 9 49! Copyright © 2011 – Kaazing Corporation 50!
Copyright © 2011 – Kaazing Corporation THANK YOU! http://kaazing.me http://kaazing.com/download.html 51! Copyright © 2011 – Kaazing Corporation The End