websockets on fire

Post on 17-May-2015

3.745 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

HTML5 WebCamps talk on WebSockets

TRANSCRIPT

WebSockets On FireHTML5 WebCamps 2011

Whois

Jef ClaesFerranti Computer Systems

@JefClaeshttp://jclaes.blogspot.comJef.claes@gmail.com

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

DIRECT COMMUNICATION between browser and

server

Chat applications

Collaborative tools

Social networking

Online gaming

But haven’t we been doing this for a while?

COMET

1. Frequent polling

Browser Server

HTTP Request

HTTP Response

GET /PollingStock//PollingStock HTTP/1.1Host: localhost:8080User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-usAccept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-aliveReferer: http://www.example.com/PollingStock/Cookie: showInheritedConstant=false; showInheritedProtectedConstant=false; showInheritedProperty=false; showInheritedProtectedProperty=false; showInheritedMethod=false; showInheritedProtectedMethod=false; showInheritedEvent=false; showInheritedStyle=false; showInheritedEffect=false

HTTP/1.x 200 OKX-Powered-By: Servlet/2.5Server: Sun Java System Application Server 9.1_02Content-Type: text/html;charset=UTF-8

Request / Response headers = 871 bytes1000 clients poll every 10 seconds

1000 * 871 bytes = 0,8MB / 10 seconds

0,8 MB * 6 = 4,8 MB / minute

4,8 MB * 60 = 288 MB / hour

288 MB * 24 = 6,912 GB /

day

2. Long polling

Wait for it...

Browser Server

HTTP Request

HTTP Response

Say NO to COMET

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

‘TCP for the Web’

Full-duplex direct communication

Browser Server

HTTP

HTTP

WebSocket

WebSocket

WebSockets HandshakeGET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U

HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa-

WebSockets message

0x00 wsMessage 0xFF

Benefits

• Native implemented• Less throughput• Performance• Complexity

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

1. HTML5

Work In Progress

2. Browser support

IE9: NoSafari 5, Chrome 10:YesFireFox 4, Opera 11: Yes, but…

Mobile: No, only Safari :-(

Source: http://caniuse.com

2. Browser support

ALTERNATIVES yesssss

- Silverlight - Flash

3. The server

HTML5 Labs (WCF)http://

html5labs.interoperabilitybridges.com pywebsocket (Apache extension) http://code.google.com/p/pywebsocket/

jWebSocket (Java)http://jwebsocket.org/

web-socket-ruby (Ruby)https://github.com/gimite/web-socket-ruby

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Why?

Information ASAP

• Information screens• Paging• JIT Printing

• Websites

Why?

1. NetViewer

2. Current Incidents

WCF WebSockets

Server

Dispatcher

Silverlight client

Silverlight client

Silverlight client

http://html5labs.interoperabilitybridges.com/

Code

Conclusion

WebSockets > COMETNot quite ready

Recommended resources

• http://dev.w3.org/html5/websockets/• http://

html5labs.interoperabilitybridges.com

• http://blogs.msdn.com/b/interoperability/archive/tags/html5/

• http://jclaes.blogspot.com

Q & A

Join us

• Twitter:– @MSDNBelux– Our tag today: #webcampbe

• Facebook: – MSDN België (NL)– MSDN BeLux (FR)

• Latest news on www.msdn.be • Always up to date: register to MSDN Flash

and Express Yourself http://www.msdn-newsletters.be

Thank you

top related