SlideShare a Scribd company logo
Let’s get real (time): Server-Sent
Events,WebSockets and WebRTC for
the soul
A guided tour of modern browser networking
Swanand Pagnis	

swanand@pagnis.in
Yours truly
• Originally from Krypton, often mistaken as the last
survivor	

• Sent to earth in a spaceship while still a baby	

• A few useful superpowers	

• Suspiciously good at hiding in plain sight
Yours truly
• Originally from Krypton, often mistaken as the last
survivor	

• Sent to earth in a spaceship while still a baby	

• A few useful superpowers	

• Suspiciously good at hiding in plain sight
Yours truly
• Bangalore RUG, Mysore RUG, Garden City
RubyConf	

• Hack code at Simplero for a living	

• Twitter @_swanand	

• Github @swanandp
What’s in store for us
1. Why bother ?
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
3. Concepts and app Integration with:
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
3. Concepts and app Integration with:
1. SSE
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
3. Concepts and app Integration with:
1. SSE
2. WebSockets
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
3. Concepts and app Integration with:
1. SSE
2. WebSockets
3. WebRTC
What’s in store for us
1. Why bother ?
2. The Zen of RealTime Communication
3. Concepts and app Integration with:
1. SSE
2. WebSockets
3. WebRTC
4. Further reading and open source opportunities
What’s in store for us
Problems with traditional approaches
Why Bother ?
1. Poor performance because of high latency	

2. Neither truly async nor truly real time, often
limited toText transfer only	

3. Either additional complexity and inconvenience
or hacky methods
7
Problems with traditional approaches
The Zen of RealTime
Communication
• Escape from Request-Response cycle	

• Do not be bound to HTTP	

• It may or may not always REST
Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul
Also known as the EventSource API
Server-Sent Events
Server-Sent Events : Introduction
12
Server-Sent Events : Introduction
1. Designed for Server to Client
communication
12
Server-Sent Events : Introduction
1. Designed for Server to Client
communication
2. Single long lived connection;
hence low latency
12
Server-Sent Events : Introduction
1. Designed for Server to Client
communication
2. Single long lived connection;
hence low latency
3. Simple cross browser API
12
Server-Sent Events : Use cases
• Activity feeds likeTwitter, Facebook,
StockTickers	

• Analytics, Dashboards, Monitoring	

• Chats, Instant Messaging *,
Collaborative editing like Google Docs
13
14
Server-Sent Events :The Browser
Server-Sent Events :The Server
15
Server-Sent Events : Summary
1. Simple Protocol that builds on top of HTTP	

2. Truly async	

3. Perfect for “notifying” the client	

4. Great cross browser support, but no binary
support
16
1. Traditional Rack based app are a slight misfit because
of response buffering ( Remember our first Zen ? )	

2. Evented architecture works in our favour (Think of
EM::Deferrable orThin )	

3. Long running connection means long running
process on the server
Server-Sent Events :App Integration
17
1. ActionController::Live	

2. Sinatra’s Streaming API	

3. Faye	

4. Cramp	

5. Pusher
Server-Sent Events :App Integration
18
1. Streaming and SSE support baked right into Rails
(  4.0 )	

2. You keep the full context ( current_user etc )	

3. Integration friendly, almost a drop-in feature into
existing Rails apps
ActionController::Live
19
EDGE
ActionController::Live
20
Sinatra’s Streaming API
1. You only need Sinatra,
Thin and some Javascript	

2. So simple, you will cry
with happiness	

3. No app context	

4. So simple, you will beg
for more features
Sinatra’s Streaming API
1. You only need Sinatra,
Thin and some Javascript	

2. So simple, you will cry
with happiness	

3. No app context	

4. So simple, you will beg
for more features
Sinatra’s Streaming API
1. Running a separate process that acts as a server, and
your server and client act as clients to this server	

2. Pub / sub model, drop-in integration with your app	

3. Graceful degradation	

4. No app context
Faye +Your App
22
Faye +Your App
Apps that have more traditional components than
real time	

1. Use a separate process / service / app for the
real time part ( e.g. Faye or Pusher or BYOT )	

2. Use existing infrastructure for non real time
aspects of the app
Recommended approach
Rant
24
Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul
WebSockets
When Server-Sent Events are just not enough
WebSockets : Introduction
27
WebSockets : Introduction
1. Standalone Bidirectional protocol
27
WebSockets : Introduction
1. Standalone Bidirectional protocol
2. Message oriented, supports events by design
27
WebSockets : Introduction
1. Standalone Bidirectional protocol
2. Message oriented, supports events by design
3. Reliable text and binary transfers
27
WebSockets : Introduction
1. Standalone Bidirectional protocol
2. Message oriented, supports events by design
3. Reliable text and binary transfers
4. HTTP Compatible
27
1. All the use cases of SSEs, plus:	

2. Multiplayer games, Multi-media chat *	

3. Remote pair programming, Online contests, Live
interviews, Screen sharing, Remote Desktop etc.
WebSockets : Use Cases
28
WebSockets :The Browser
WebSockets : Upgrade Handshake
1. Faye +Your app	

2. Cramp +Your app	

3. websocket-rails	

4. em-websocket, em-websocket-rails	

5. Pusher
WebSocket
WebSockets :App Integration
31
Cramp +Your App
32
1. Run Cramp as a standalone app	

2. Provides an app like functionality around RTC	

3. Think of it as Rails for real time apps	

4. No drop-in integration with existing app
Cramp +Your App
33
1. Controller becomes Action	

2. Action becomes Event, triggered with on_data	

3. params become data	

4. Connection open by default
Recommended approach
34
Apps that are heavily real time	

1. Use Cramp to build a stand alone app	

2. Be an API consumer for your other app for any
additional functionality
Rant
Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul
http://www.personal.psu.edu/afr3/blogs/siowfa13/yawning.jpg
Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul
Modern Day Kazaa, in an Iron Man Suit
WebRTC
WebRTC : Introduction
39
1. Peer-to-peer audio, video, and data sharing
between browsers	

2. Standardised to a JavaScript API	

3. Google Backed
WebRTC : Introduction
40
1. Acquire Audio andVideo data	

2. Communicate Audio andVideo data	

3. Communicate Arbitrary Application Data
WebRTC : Introduction
41
1. MediaStream	

2. RTCPeerConnection	

3. RTCDataChannel
WebRTC : Introduction
42
1. MediaStream	

2. RTCPeerConnection	

3. RTCDataChannel
WebRTC : Typical Workflow - Phase 1
43
WebRTC : Typical Workflow - Phase 1
43
1. Connect to the Signalling Server, let it know:	

1. Your Identity ( STUN )	

2. How to reach you ( ICE Candidate )	

2. Once a peer is detected by the server, it in turns gives you
the above info	

3. At this point, we are ready for a P2P connection
WebRTC : Typical Workflow - Phase 1
Incomplete
Code
WebRTC : Typical Workflow - Phase II
45
WebRTC : Typical Workflow - Phase II
45
1. Create a stream to send and receive binary data	

2. Create a channel to send and receive text data	

3. Actually send and receive data
WebRTC : Typical Workflow - Phase II
– Oscar Wilde
“Consistency is the last refuge of the unimaginative”
WebRTC : Use Cases
48
1. Motherlode of Skype clones, free and open
source!	

2. Screen sharing, remote pairing, multiplayer games,
browser based torrents, Live MOOCs	

3. In reality, this is limited mostly by our imagination
and browser’s computing abilities
WebRTC : Dive in
49
1. Use any of the JavaScript libs / SDKs :	

1. Open Source: SimpleWebRTC, webRTC.io, PeerJS,
EasyRTC, ShareFest	

2. Commercial: PubNub WebRTC SDK	

2. Signalling service example in Ruby	

1. OSS : github.com/palavatv/palava-machine
Further Reading
• HTML5Rocks ( it’s a website, not a collection of
rocks )	

• http://studio.html5rocks.com/	

• WebRTC official website	

• Mozilla Developer Network	

• http://simpl.info/
Websites
• Ilya Grigorik	

• Sam Dutton	

• Paul Irish	

• Eric Bidelman	

• Your own blog, one year from now
Blogs
• High Performance Browser Networking	

• Getting Started with WebRTC	

• HTML5: Up and Running
Books
Open Source
Opportunities
• Help out Faye, Cramp and other libraries
mentioned so far	

• Open source all your throw-away code written
during learning ( Mine is on Github )	

• Async-proof versions of commonly needed ruby
gems ( e.g. github.com/rkh/async-rack )
• Helper Libraries for Cramp, e.g.	

• To easily build simple board games	

• To write calendar based real time apps	

• Augment the testing libraries to test real time stuff	

• Write and make your benchmarks available
ThankYou !
57
Questions ?
58

More Related Content

What's hot

Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
Yan Cui
 
Building Fault Tolerant Microservices
Building Fault Tolerant MicroservicesBuilding Fault Tolerant Microservices
Building Fault Tolerant Microservices
Kristoffer Erlandsson
 
Let's not rewrite it all
Let's not rewrite it allLet's not rewrite it all
Let's not rewrite it all
Michelle Brush
 
Pulsar for Kafka People
Pulsar for Kafka PeoplePulsar for Kafka People
Pulsar for Kafka People
Jesse Anderson
 
Realtime html5 multiplayer_games_with_node_js
Realtime html5 multiplayer_games_with_node_jsRealtime html5 multiplayer_games_with_node_js
Realtime html5 multiplayer_games_with_node_js
Mario Gonzalez
 
New AWS Services
New AWS ServicesNew AWS Services
New AWS Services
Josh Padnick
 
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
Amazon Web Services Korea
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka Streams
Konrad Malawski
 
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
Adrian Cockcroft
 
Interop 2011 - Scaling Platform As A Service
Interop 2011 - Scaling Platform As A ServiceInterop 2011 - Scaling Platform As A Service
Interop 2011 - Scaling Platform As A Service
Patrick Chanezon
 
Beware the potholes
Beware the potholesBeware the potholes
Beware the potholes
Yan Cui
 
Android push-applications-android
Android push-applications-androidAndroid push-applications-android
Android push-applications-android
wadise
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
David Hoerster
 
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
VMware Tanzu
 
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECS
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECSAutomating Zero-Downtime Production Cluster Upgrades for Amazon ECS
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECS
Matt Callanan
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)
Tammy Everts
 
Data Driven Security, from Gartner Security Summit 2012
Data Driven Security, from Gartner Security Summit 2012Data Driven Security, from Gartner Security Summit 2012
Data Driven Security, from Gartner Security Summit 2012
Nick Galbreath
 
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live VideoCodemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
Akhilesh Gupta
 
Docker Cluster Management with ECS
Docker Cluster Management with ECSDocker Cluster Management with ECS
Docker Cluster Management with ECS
Matt Callanan
 
Svc 202-netflix-open-source
Svc 202-netflix-open-sourceSvc 202-netflix-open-source
Svc 202-netflix-open-source
Ruslan Meshenberg
 

What's hot (20)

Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
 
Building Fault Tolerant Microservices
Building Fault Tolerant MicroservicesBuilding Fault Tolerant Microservices
Building Fault Tolerant Microservices
 
Let's not rewrite it all
Let's not rewrite it allLet's not rewrite it all
Let's not rewrite it all
 
Pulsar for Kafka People
Pulsar for Kafka PeoplePulsar for Kafka People
Pulsar for Kafka People
 
Realtime html5 multiplayer_games_with_node_js
Realtime html5 multiplayer_games_with_node_jsRealtime html5 multiplayer_games_with_node_js
Realtime html5 multiplayer_games_with_node_js
 
New AWS Services
New AWS ServicesNew AWS Services
New AWS Services
 
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
[AWS Dev Day] 이머징 테크 | Libra 소스코드분석 및 AWS에서 블록체인 기반 지불 시스템 최적화 방법 - 박혜영 AWS 솔...
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka Streams
 
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
Monitorama - Please, no more Minutes, Milliseconds, Monoliths or Monitoring T...
 
Interop 2011 - Scaling Platform As A Service
Interop 2011 - Scaling Platform As A ServiceInterop 2011 - Scaling Platform As A Service
Interop 2011 - Scaling Platform As A Service
 
Beware the potholes
Beware the potholesBeware the potholes
Beware the potholes
 
Android push-applications-android
Android push-applications-androidAndroid push-applications-android
Android push-applications-android
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
Spring Boot Omakase: A Fast-Paced “Chef’s Choice” Dive into Fun and Useful To...
 
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECS
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECSAutomating Zero-Downtime Production Cluster Upgrades for Amazon ECS
Automating Zero-Downtime Production Cluster Upgrades for Amazon ECS
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)
 
Data Driven Security, from Gartner Security Summit 2012
Data Driven Security, from Gartner Security Summit 2012Data Driven Security, from Gartner Security Summit 2012
Data Driven Security, from Gartner Security Summit 2012
 
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live VideoCodemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
 
Docker Cluster Management with ECS
Docker Cluster Management with ECSDocker Cluster Management with ECS
Docker Cluster Management with ECS
 
Svc 202-netflix-open-source
Svc 202-netflix-open-sourceSvc 202-netflix-open-source
Svc 202-netflix-open-source
 

Similar to Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul

Iot meets Serverless
Iot meets ServerlessIot meets Serverless
Iot meets Serverless
Narendran R
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
Antonio Peric-Mazar
 
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsAsynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Christian Heindel
 
Real Time Realitites
Real Time RealititesReal Time Realitites
Real Time Realitites
markisuak
 
Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015
Amura Marketing Technologies Pvt. Ltd.
 
Increasing velocity via serless semantics
Increasing velocity via serless semanticsIncreasing velocity via serless semantics
Increasing velocity via serless semantics
Kfir Bloch
 
ServerSentEventsV2.pdf
ServerSentEventsV2.pdfServerSentEventsV2.pdf
ServerSentEventsV2.pdf
Alessandro Minoccheri
 
Best practices of building data streaming API
Best practices of building data streaming APIBest practices of building data streaming API
Best practices of building data streaming API
Constantine Slisenka
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
John Adams
 
Real time web
Real time webReal time web
Real time web
Medhat Dawoud
 
ServerSentEvents.pdf
ServerSentEvents.pdfServerSentEvents.pdf
ServerSentEvents.pdf
Alessandro Minoccheri
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Alberto González Trastoy
 
Device APIs at TakeOff Conference
Device APIs at TakeOff ConferenceDevice APIs at TakeOff Conference
Device APIs at TakeOff Conference
dianacheng
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
Doris Chen
 
Web sockets - Pentesting
Web sockets - Pentesting Web sockets - Pentesting
Web sockets - Pentesting
Vandana Verma
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...
Peter Gfader
 
video conference (peer to peer)
video conference (peer to peer)video conference (peer to peer)
video conference (peer to peer)
mohamed amr
 
Janus/HOMER/HEPIC @ OpenSIPS18
Janus/HOMER/HEPIC @ OpenSIPS18Janus/HOMER/HEPIC @ OpenSIPS18
Janus/HOMER/HEPIC @ OpenSIPS18
Lorenzo Miniero
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
Websocket 101 in Python
Websocket 101 in PythonWebsocket 101 in Python
Websocket 101 in Python
Juti Noppornpitak
 

Similar to Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul (20)

Iot meets Serverless
Iot meets ServerlessIot meets Serverless
Iot meets Serverless
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
 
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsAsynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
 
Real Time Realitites
Real Time RealititesReal Time Realitites
Real Time Realitites
 
Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015Pune Ruby Meetup - November 2015
Pune Ruby Meetup - November 2015
 
Increasing velocity via serless semantics
Increasing velocity via serless semanticsIncreasing velocity via serless semantics
Increasing velocity via serless semantics
 
ServerSentEventsV2.pdf
ServerSentEventsV2.pdfServerSentEventsV2.pdf
ServerSentEventsV2.pdf
 
Best practices of building data streaming API
Best practices of building data streaming APIBest practices of building data streaming API
Best practices of building data streaming API
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Real time web
Real time webReal time web
Real time web
 
ServerSentEvents.pdf
ServerSentEvents.pdfServerSentEvents.pdf
ServerSentEvents.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Device APIs at TakeOff Conference
Device APIs at TakeOff ConferenceDevice APIs at TakeOff Conference
Device APIs at TakeOff Conference
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
 
Web sockets - Pentesting
Web sockets - Pentesting Web sockets - Pentesting
Web sockets - Pentesting
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...
 
video conference (peer to peer)
video conference (peer to peer)video conference (peer to peer)
video conference (peer to peer)
 
Janus/HOMER/HEPIC @ OpenSIPS18
Janus/HOMER/HEPIC @ OpenSIPS18Janus/HOMER/HEPIC @ OpenSIPS18
Janus/HOMER/HEPIC @ OpenSIPS18
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Websocket 101 in Python
Websocket 101 in PythonWebsocket 101 in Python
Websocket 101 in Python
 

Recently uploaded

The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
Inglês no Mundo Digital
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Torry Harris
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
Ivanti
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
paysquare consultancy
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
CEPTES Software Inc
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
aslasdfmkhan4750
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
kumarjarun2010
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 

Recently uploaded (20)

The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdfARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
ARTIFICIAL INTELLIGENCE (AI) IN MUSIC.pdf
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 

Let's Get Real (time): Server-Sent Events, WebSockets and WebRTC for the soul

  • 1. Let’s get real (time): Server-Sent Events,WebSockets and WebRTC for the soul A guided tour of modern browser networking Swanand Pagnis swanand@pagnis.in
  • 2. Yours truly • Originally from Krypton, often mistaken as the last survivor • Sent to earth in a spaceship while still a baby • A few useful superpowers • Suspiciously good at hiding in plain sight
  • 3. Yours truly • Originally from Krypton, often mistaken as the last survivor • Sent to earth in a spaceship while still a baby • A few useful superpowers • Suspiciously good at hiding in plain sight
  • 4. Yours truly • Bangalore RUG, Mysore RUG, Garden City RubyConf • Hack code at Simplero for a living • Twitter @_swanand • Github @swanandp
  • 6. 1. Why bother ? What’s in store for us
  • 7. 1. Why bother ? 2. The Zen of RealTime Communication What’s in store for us
  • 8. 1. Why bother ? 2. The Zen of RealTime Communication 3. Concepts and app Integration with: What’s in store for us
  • 9. 1. Why bother ? 2. The Zen of RealTime Communication 3. Concepts and app Integration with: 1. SSE What’s in store for us
  • 10. 1. Why bother ? 2. The Zen of RealTime Communication 3. Concepts and app Integration with: 1. SSE 2. WebSockets What’s in store for us
  • 11. 1. Why bother ? 2. The Zen of RealTime Communication 3. Concepts and app Integration with: 1. SSE 2. WebSockets 3. WebRTC What’s in store for us
  • 12. 1. Why bother ? 2. The Zen of RealTime Communication 3. Concepts and app Integration with: 1. SSE 2. WebSockets 3. WebRTC 4. Further reading and open source opportunities What’s in store for us
  • 13. Problems with traditional approaches Why Bother ?
  • 14. 1. Poor performance because of high latency 2. Neither truly async nor truly real time, often limited toText transfer only 3. Either additional complexity and inconvenience or hacky methods 7
  • 15. Problems with traditional approaches The Zen of RealTime Communication
  • 16. • Escape from Request-Response cycle • Do not be bound to HTTP • It may or may not always REST
  • 18. Also known as the EventSource API Server-Sent Events
  • 19. Server-Sent Events : Introduction 12
  • 20. Server-Sent Events : Introduction 1. Designed for Server to Client communication 12
  • 21. Server-Sent Events : Introduction 1. Designed for Server to Client communication 2. Single long lived connection; hence low latency 12
  • 22. Server-Sent Events : Introduction 1. Designed for Server to Client communication 2. Single long lived connection; hence low latency 3. Simple cross browser API 12
  • 23. Server-Sent Events : Use cases • Activity feeds likeTwitter, Facebook, StockTickers • Analytics, Dashboards, Monitoring • Chats, Instant Messaging *, Collaborative editing like Google Docs 13
  • 26. Server-Sent Events : Summary 1. Simple Protocol that builds on top of HTTP 2. Truly async 3. Perfect for “notifying” the client 4. Great cross browser support, but no binary support 16
  • 27. 1. Traditional Rack based app are a slight misfit because of response buffering ( Remember our first Zen ? ) 2. Evented architecture works in our favour (Think of EM::Deferrable orThin ) 3. Long running connection means long running process on the server Server-Sent Events :App Integration 17
  • 28. 1. ActionController::Live 2. Sinatra’s Streaming API 3. Faye 4. Cramp 5. Pusher Server-Sent Events :App Integration 18
  • 29. 1. Streaming and SSE support baked right into Rails ( 4.0 ) 2. You keep the full context ( current_user etc ) 3. Integration friendly, almost a drop-in feature into existing Rails apps ActionController::Live 19
  • 32. 1. You only need Sinatra, Thin and some Javascript 2. So simple, you will cry with happiness 3. No app context 4. So simple, you will beg for more features Sinatra’s Streaming API
  • 33. 1. You only need Sinatra, Thin and some Javascript 2. So simple, you will cry with happiness 3. No app context 4. So simple, you will beg for more features Sinatra’s Streaming API
  • 34. 1. Running a separate process that acts as a server, and your server and client act as clients to this server 2. Pub / sub model, drop-in integration with your app 3. Graceful degradation 4. No app context Faye +Your App 22
  • 36. Apps that have more traditional components than real time 1. Use a separate process / service / app for the real time part ( e.g. Faye or Pusher or BYOT ) 2. Use existing infrastructure for non real time aspects of the app Recommended approach Rant 24
  • 38. WebSockets When Server-Sent Events are just not enough
  • 40. WebSockets : Introduction 1. Standalone Bidirectional protocol 27
  • 41. WebSockets : Introduction 1. Standalone Bidirectional protocol 2. Message oriented, supports events by design 27
  • 42. WebSockets : Introduction 1. Standalone Bidirectional protocol 2. Message oriented, supports events by design 3. Reliable text and binary transfers 27
  • 43. WebSockets : Introduction 1. Standalone Bidirectional protocol 2. Message oriented, supports events by design 3. Reliable text and binary transfers 4. HTTP Compatible 27
  • 44. 1. All the use cases of SSEs, plus: 2. Multiplayer games, Multi-media chat * 3. Remote pair programming, Online contests, Live interviews, Screen sharing, Remote Desktop etc. WebSockets : Use Cases 28
  • 46. WebSockets : Upgrade Handshake
  • 47. 1. Faye +Your app 2. Cramp +Your app 3. websocket-rails 4. em-websocket, em-websocket-rails 5. Pusher WebSocket WebSockets :App Integration 31
  • 48. Cramp +Your App 32 1. Run Cramp as a standalone app 2. Provides an app like functionality around RTC 3. Think of it as Rails for real time apps 4. No drop-in integration with existing app
  • 49. Cramp +Your App 33 1. Controller becomes Action 2. Action becomes Event, triggered with on_data 3. params become data 4. Connection open by default
  • 50. Recommended approach 34 Apps that are heavily real time 1. Use Cramp to build a stand alone app 2. Be an API consumer for your other app for any additional functionality Rant
  • 54. Modern Day Kazaa, in an Iron Man Suit WebRTC
  • 55. WebRTC : Introduction 39 1. Peer-to-peer audio, video, and data sharing between browsers 2. Standardised to a JavaScript API 3. Google Backed
  • 56. WebRTC : Introduction 40 1. Acquire Audio andVideo data 2. Communicate Audio andVideo data 3. Communicate Arbitrary Application Data
  • 57. WebRTC : Introduction 41 1. MediaStream 2. RTCPeerConnection 3. RTCDataChannel
  • 58. WebRTC : Introduction 42 1. MediaStream 2. RTCPeerConnection 3. RTCDataChannel
  • 59. WebRTC : Typical Workflow - Phase 1 43
  • 60. WebRTC : Typical Workflow - Phase 1 43 1. Connect to the Signalling Server, let it know: 1. Your Identity ( STUN ) 2. How to reach you ( ICE Candidate ) 2. Once a peer is detected by the server, it in turns gives you the above info 3. At this point, we are ready for a P2P connection
  • 61. WebRTC : Typical Workflow - Phase 1 Incomplete Code
  • 62. WebRTC : Typical Workflow - Phase II 45
  • 63. WebRTC : Typical Workflow - Phase II 45 1. Create a stream to send and receive binary data 2. Create a channel to send and receive text data 3. Actually send and receive data
  • 64. WebRTC : Typical Workflow - Phase II
  • 65. – Oscar Wilde “Consistency is the last refuge of the unimaginative”
  • 66. WebRTC : Use Cases 48 1. Motherlode of Skype clones, free and open source! 2. Screen sharing, remote pairing, multiplayer games, browser based torrents, Live MOOCs 3. In reality, this is limited mostly by our imagination and browser’s computing abilities
  • 67. WebRTC : Dive in 49 1. Use any of the JavaScript libs / SDKs : 1. Open Source: SimpleWebRTC, webRTC.io, PeerJS, EasyRTC, ShareFest 2. Commercial: PubNub WebRTC SDK 2. Signalling service example in Ruby 1. OSS : github.com/palavatv/palava-machine
  • 69. • HTML5Rocks ( it’s a website, not a collection of rocks ) • http://studio.html5rocks.com/ • WebRTC official website • Mozilla Developer Network • http://simpl.info/ Websites
  • 70. • Ilya Grigorik • Sam Dutton • Paul Irish • Eric Bidelman • Your own blog, one year from now Blogs
  • 71. • High Performance Browser Networking • Getting Started with WebRTC • HTML5: Up and Running Books
  • 73. • Help out Faye, Cramp and other libraries mentioned so far • Open source all your throw-away code written during learning ( Mine is on Github ) • Async-proof versions of commonly needed ruby gems ( e.g. github.com/rkh/async-rack )
  • 74. • Helper Libraries for Cramp, e.g. • To easily build simple board games • To write calendar based real time apps • Augment the testing libraries to test real time stuff • Write and make your benchmarks available