SlideShare a Scribd company logo
1 of 18
Download to read offline
WebSocket for Dummies
Bartosz Zaczyński
bartosz.zaczynski@grandparade.co.uk
TCP/IP Socket
http://www.freeimages.co.uk/
Protocol
http://www.freeimages.co.uk/
Protocol: telnet
Protocol: HTTP
Protocol: HTTPS
Protocol: fixed length message
Protocol: message delimiter
Example: Betradar TCP/SSL
@tornado.gen.coroutine
def receive(self):
"""Read CRLF-delimited messages and push them onto the queue."""
try:
if not self.iostream.closed():
message_body = yield self.iostream.read_until('rnrn')
logger.debug('Received message: %s', message_body.strip())
received_at = datetime.datetime.utcnow()
message = parser.parse(message_body, received_at)
if message is not None:
if self.is_whitelisted(message):
self.messages.enqueue(message)
self.log(message)
self.ioloop.add_callback(self.receive)
except tornado.iostream.StreamClosedError:
if not self._closing:
logger.error('Betradar connection closed by remote endpoint')
self.heartbeat.stop()
if self.on_closed:
self.on_closed()
WebSocket: handshake
WebSocket: server frame
WebSocket: client frame
WebSocket: JavaScript API
<!DOCTYPE html>
<html>
<head>
<title>WebSocket Demo</title>
<script>
var ws = new WebSocket("ws://localhost:8080/websocket");
ws.onopen = function(event) { console.log("open"); };
ws.onclose = function(event) { console.log("closed"); };
ws.onerror = function(event) { console.log("error"); };
ws.onmessage = function(event) { console.log(event.data); };
function onButtonClick() {
ws.send(document.getElementById("message").value)
}
</script>
</head>
<body>
<input type="text" id="message">
<button type="button" onclick="onButtonClick();">Send</button>
</body>
</html>
WebSocket: JavaScript libs
var ws = STOMP.over(new SockJS("/websocket"));
var ws = io.connect("http://localhost:8080/websocket");
UNSUBSCRIBE
id:sub-0
u0000
SUBSCRIBE
id:sub-0
destination:/topic/chat.all
u0000
WebSocket: sub protocol
CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000
u0000
CONNECTEDversion:1.1heart-beat:0,0
u0000
MESSAGE
subscription:sub-0
message-id:007
destination:/topic/chat.all
content-type:text/plain
content-length:11
hello worldu0000
SEND
destination:/topic/chat.all
content-type:text/plain
hello worldu0000
Debugging
Summary
1. Lightweight binary protocol on top of TCP.
2. Different from HTTP (except for the handshake).
3. Replaces AJAX polling and plug­ins such as Flash.
Q&A
Bartosz Zaczyński
bartosz.zaczynski@grandparade.co.uk

More Related Content

What's hot

Using MMS to Build New Environments
Using MMS to Build New EnvironmentsUsing MMS to Build New Environments
Using MMS to Build New Environments
MongoDB
 
Dicas e truques de otimização de websites python
Dicas e truques de otimização de websites pythonDicas e truques de otimização de websites python
Dicas e truques de otimização de websites python
Fabiano Weimar
 
Python session.11 By Shanmugam
Python session.11 By ShanmugamPython session.11 By Shanmugam
Python session.11 By Shanmugam
Navaneethan Naveen
 
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration ChannelsEfail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
Priyanka Aash
 

What's hot (20)

OSMC 2012 | Distributed Monitoring mit NSClient++ by Michael Medin
OSMC 2012 | Distributed Monitoring mit NSClient++ by Michael MedinOSMC 2012 | Distributed Monitoring mit NSClient++ by Michael Medin
OSMC 2012 | Distributed Monitoring mit NSClient++ by Michael Medin
 
Dos threats and countermeasures
Dos threats and countermeasuresDos threats and countermeasures
Dos threats and countermeasures
 
Using MMS to Build New Environments
Using MMS to Build New EnvironmentsUsing MMS to Build New Environments
Using MMS to Build New Environments
 
WordPress Performance Tuning
WordPress Performance TuningWordPress Performance Tuning
WordPress Performance Tuning
 
Buffer overflow for Beginners
Buffer overflow for BeginnersBuffer overflow for Beginners
Buffer overflow for Beginners
 
Smb 3-odx-traffic
Smb 3-odx-trafficSmb 3-odx-traffic
Smb 3-odx-traffic
 
Uable to do ssh from the RedHat Linux machine to Netapp filer 7 mode storage ...
Uable to do ssh from the RedHat Linux machine to Netapp filer 7 mode storage ...Uable to do ssh from the RedHat Linux machine to Netapp filer 7 mode storage ...
Uable to do ssh from the RedHat Linux machine to Netapp filer 7 mode storage ...
 
Dicas e truques de otimização de websites python
Dicas e truques de otimização de websites pythonDicas e truques de otimização de websites python
Dicas e truques de otimização de websites python
 
Mastering JUNOS DHCP
Mastering JUNOS DHCPMastering JUNOS DHCP
Mastering JUNOS DHCP
 
Metodologias de Programação IV - Aula 4, Secção 2 - Suporte para sessões no p...
Metodologias de Programação IV - Aula 4, Secção 2 - Suporte para sessões no p...Metodologias de Programação IV - Aula 4, Secção 2 - Suporte para sessões no p...
Metodologias de Programação IV - Aula 4, Secção 2 - Suporte para sessões no p...
 
Python session.11 By Shanmugam
Python session.11 By ShanmugamPython session.11 By Shanmugam
Python session.11 By Shanmugam
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commands
 
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
 
Client–server model
Client–server modelClient–server model
Client–server model
 
SMB3 Offload Data Transfer (ODX)
SMB3 Offload Data Transfer (ODX)SMB3 Offload Data Transfer (ODX)
SMB3 Offload Data Transfer (ODX)
 
Neo4j after 1 year in production
Neo4j after 1 year in productionNeo4j after 1 year in production
Neo4j after 1 year in production
 
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration ChannelsEfail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels
 
Creating qmgr and allowing remote authorization
Creating qmgr and allowing remote authorizationCreating qmgr and allowing remote authorization
Creating qmgr and allowing remote authorization
 
TLS/SSL MAC security flaw
TLS/SSL MAC security flawTLS/SSL MAC security flaw
TLS/SSL MAC security flaw
 
Harden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated EvasionsHarden Security Devices Against Increasingly Sophisticated Evasions
Harden Security Devices Against Increasingly Sophisticated Evasions
 

Similar to Bartosz Zaczyński (Grand Parade Poland) - WebSocket for Dummies

How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?
Microsoft
 
Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3
HyeonSeok Choi
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
DefconRussia
 
Layer 7 ddos
Layer 7 ddosLayer 7 ddos
Layer 7 ddos
fangjiafu
 

Similar to Bartosz Zaczyński (Grand Parade Poland) - WebSocket for Dummies (20)

How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?
 
Rpi python web
Rpi python webRpi python web
Rpi python web
 
Web Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The BasicsWeb Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The Basics
 
Browser Security
Browser SecurityBrowser Security
Browser Security
 
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
 
OpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowOpenSSL Basic Function Call Flow
OpenSSL Basic Function Call Flow
 
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
 
Http request&response
Http request&responseHttp request&response
Http request&response
 
Building an inflight entertainment system controller in twisted
Building an inflight entertainment system controller in twistedBuilding an inflight entertainment system controller in twisted
Building an inflight entertainment system controller in twisted
 
Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3
 
OpenSSL programming (still somewhat initial version)
OpenSSL programming (still somewhat initial version)OpenSSL programming (still somewhat initial version)
OpenSSL programming (still somewhat initial version)
 
Jetty TLS troubleshooting
Jetty TLS troubleshootingJetty TLS troubleshooting
Jetty TLS troubleshooting
 
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
Rust Hack
Rust HackRust Hack
Rust Hack
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
 
jkljklj
jkljkljjkljklj
jkljklj
 
Layer 7 ddos
Layer 7 ddosLayer 7 ddos
Layer 7 ddos
 

More from Business Link Krakow

More from Business Link Krakow (20)

Bartosz Grzybowski - Continuous integration, czyli code quality matters
Bartosz Grzybowski - Continuous integration, czyli code quality mattersBartosz Grzybowski - Continuous integration, czyli code quality matters
Bartosz Grzybowski - Continuous integration, czyli code quality matters
 
Grzegorz Sikorskie - "Gorsze jest lepsze", czyli o dobrych stronach złego kodu
Grzegorz Sikorskie - "Gorsze jest lepsze", czyli o dobrych stronach złego koduGrzegorz Sikorskie - "Gorsze jest lepsze", czyli o dobrych stronach złego kodu
Grzegorz Sikorskie - "Gorsze jest lepsze", czyli o dobrych stronach złego kodu
 
Konrad Kwiatkowski - Type of components in React/Redux
Konrad Kwiatkowski - Type of components in React/ReduxKonrad Kwiatkowski - Type of components in React/Redux
Konrad Kwiatkowski - Type of components in React/Redux
 
Oferta sale
Oferta saleOferta sale
Oferta sale
 
Oferta miejsca pracy Business Link Kraków
Oferta miejsca pracy Business Link KrakówOferta miejsca pracy Business Link Kraków
Oferta miejsca pracy Business Link Kraków
 
Paweł Kowalczyk (Codete) - Continuous integration for iOS
Paweł Kowalczyk (Codete) - Continuous integration for iOSPaweł Kowalczyk (Codete) - Continuous integration for iOS
Paweł Kowalczyk (Codete) - Continuous integration for iOS
 
Mateusz Zając (Codete) - Swift in Production
Mateusz Zając (Codete)  - Swift in ProductionMateusz Zając (Codete)  - Swift in Production
Mateusz Zając (Codete) - Swift in Production
 
Jakub Mrowiec (Grand Parade Poland) - Monumentum Case Study
Jakub Mrowiec (Grand Parade Poland) - Monumentum Case StudyJakub Mrowiec (Grand Parade Poland) - Monumentum Case Study
Jakub Mrowiec (Grand Parade Poland) - Monumentum Case Study
 
Piotr Grabski-Gradziński (VML) - To jak zrobimy ten projekt? Czyli o doborze ...
Piotr Grabski-Gradziński (VML) - To jak zrobimy ten projekt? Czyli o doborze ...Piotr Grabski-Gradziński (VML) - To jak zrobimy ten projekt? Czyli o doborze ...
Piotr Grabski-Gradziński (VML) - To jak zrobimy ten projekt? Czyli o doborze ...
 
Paweł Dyrek (Codete) - Product Delivery
Paweł Dyrek (Codete) - Product DeliveryPaweł Dyrek (Codete) - Product Delivery
Paweł Dyrek (Codete) - Product Delivery
 
Maciej Malarz (Codete) - Database? Meh, implementation detail
Maciej Malarz (Codete) - Database? Meh, implementation detailMaciej Malarz (Codete) - Database? Meh, implementation detail
Maciej Malarz (Codete) - Database? Meh, implementation detail
 
Mateusz Chłodnicki - Case study: Shuttout.com
Mateusz Chłodnicki - Case study: Shuttout.comMateusz Chłodnicki - Case study: Shuttout.com
Mateusz Chłodnicki - Case study: Shuttout.com
 
Tomasz Chołast - Case study: zrzutka.pl
Tomasz Chołast - Case study: zrzutka.plTomasz Chołast - Case study: zrzutka.pl
Tomasz Chołast - Case study: zrzutka.pl
 
Mateusz Hauschild - Jak crowdfunding zmienił rynek gier planszowych?
Mateusz Hauschild - Jak crowdfunding zmienił rynek gier planszowych?Mateusz Hauschild - Jak crowdfunding zmienił rynek gier planszowych?
Mateusz Hauschild - Jak crowdfunding zmienił rynek gier planszowych?
 
Filip Karkosz & Dominik Szloński - Jak z zaangażowania konsumenta uczynić źró...
Filip Karkosz & Dominik Szloński - Jak z zaangażowania konsumenta uczynić źró...Filip Karkosz & Dominik Szloński - Jak z zaangażowania konsumenta uczynić źró...
Filip Karkosz & Dominik Szloński - Jak z zaangażowania konsumenta uczynić źró...
 
Marek Cieśla - Kickstarter.com
Marek Cieśla - Kickstarter.comMarek Cieśla - Kickstarter.com
Marek Cieśla - Kickstarter.com
 
Bartosz Filip Malinowski - Crowdsourcing dla Starbucksa, małych startupów i o...
Bartosz Filip Malinowski - Crowdsourcing dla Starbucksa, małych startupów i o...Bartosz Filip Malinowski - Crowdsourcing dla Starbucksa, małych startupów i o...
Bartosz Filip Malinowski - Crowdsourcing dla Starbucksa, małych startupów i o...
 
Crowdinvesting - inwestycyjne modele crowdfundingu - Karol Król
Crowdinvesting - inwestycyjne modele crowdfundingu - Karol KrólCrowdinvesting - inwestycyjne modele crowdfundingu - Karol Król
Crowdinvesting - inwestycyjne modele crowdfundingu - Karol Król
 
Fundusze UE - nowe szanse, nowe możliwości dla start-up na lata 2014-2020
Fundusze UE - nowe szanse, nowe możliwości dla start-up na lata 2014-2020Fundusze UE - nowe szanse, nowe możliwości dla start-up na lata 2014-2020
Fundusze UE - nowe szanse, nowe możliwości dla start-up na lata 2014-2020
 
Pułapki podatkowe
Pułapki podatkowe Pułapki podatkowe
Pułapki podatkowe
 

Recently uploaded

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (8)

Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
Thane 💋 Call Girls 7738631006 💋 Call Girls in Thane Escort service book now. ...
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 

Bartosz Zaczyński (Grand Parade Poland) - WebSocket for Dummies