Top Banner
Web Sockets are not Just for Web Browsers September 2013
28
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Sockets are not Just for Web Browsers

Web Sockets are not Just for Web Browsers

September 2013

Page 2: Web Sockets are not Just for Web Browsers

About Me I am a software developer, based out of Phoenix, Arizona, that

specializes in .NET technology.

Expert on just about all areas of MS.NET programming, but focused on, but not limited to Connected Systems Technologies

Windows Communication Foundation (WCF)

BizTalk

Windows Workflow Foundation (WF)

SQL Server

Senior Consultant for Neudesic, LLC

President of Phoenix Connected Systems User Group

Page 3: Web Sockets are not Just for Web Browsers

What the Heck are

they?Web Sockets

Overview

We got a problemDilemmas With Traditional Methods Ladies and

Gents, We Have a Solution

Solving the request response dilemma

Where are the 1s and 0s:Code Bits and Demonstration

Meat of the Presentation:

Web Sockets beyond web browsers

Wrap it Up Already!

Conclusion, Questions and

Answers

But Why?:Why Use Web Sockets Beyond Web Browsers

3

1

2

Page 4: Web Sockets are not Just for Web Browsers

What are Web Sockets?

Web Sockets are a standard created by the W3C as developed as a part of the HTML5 initiative

RFC 6455 defines constraints for a protocol Bi-directional session-ful

communication between client and server

Beats old school polling conventions

Request Response Dilemma

API for using Web Sockets

Page 5: Web Sockets are not Just for Web Browsers

Key Take-Aways

Is it request response? Nope. It’s Full duplex.

More on this later…

Page 6: Web Sockets are not Just for Web Browsers

What Else?

Solves world hunger!!!!

Well, not really, but it’s still pretty awesome

Page 7: Web Sockets are not Just for Web Browsers

We Got a Problem Here: Request / Response Dilemma

Request: I need ‘XYZ’ resource

Response: Here is ‘XYZ’ resource

Client Server

Page 8: Web Sockets are not Just for Web Browsers

JavaScript Solutions

How do we circumvent the fact that we can’t receive events on the client from the server?

JavaScript polling Short Polling

Client checks every so often for events and messages that the server has queued

Long Polling Client makes 60 – 120 second connections to the server and waits for events

during that time

If no events are received, the server closes the session

Rinse and repeat

Page 9: Web Sockets are not Just for Web Browsers

Short Polling

Page 10: Web Sockets are not Just for Web Browsers

Long Polling

Page 11: Web Sockets are not Just for Web Browsers

I bet you have a question right about now…

What are we ever to do????

Page 12: Web Sockets are not Just for Web Browsers

Please… let me catch my breath

Don’t fret. Let me back up a second and catch my breath…

Page 13: Web Sockets are not Just for Web Browsers

Web Sockets: The Solution to the Request / Response Dilemma

Web Sockets are full duplex

Walkthrough of the process: Client establishes web socket connection to server

4 minutes pass

Server determines that an event needs to be sent to the client

Event sent through established connection

Problem solved!!

Important takeaway: Connection is synchronous (connect > disconnect), but messages are asynchronous

Page 14: Web Sockets are not Just for Web Browsers

Solution Overview

Page 15: Web Sockets are not Just for Web Browsers

Full duplex!

Full duplex from a web brower???

This is awesome!

Page 16: Web Sockets are not Just for Web Browsers

Full duplex!

However, I won’t believe it until I see it

Page 17: Web Sockets are not Just for Web Browsers

Show me the code!

Page 18: Web Sockets are not Just for Web Browsers

Web Sockets are not Just for Web Browsers

As of version 4.5, .NET WCF supports Web Sockets Web Sockets are easily implemented using the netHttpBinding

Full Duplex services

Existing service can quickly and easily add a netHttpBinding to the configuration in order to implement this

Shortly, I will show you just how that is done

Page 19: Web Sockets are not Just for Web Browsers

You’re probably wondering…

Wait a second Chris… You’re telling me that I can use other applications other than web browsers?

Page 20: Web Sockets are not Just for Web Browsers

The Truth and Nothing but the Truth

Yes my friend. This is the magic of open source protocols.

“How?”, you ask. I’ll show you how!

Page 21: Web Sockets are not Just for Web Browsers

Show me the code again!

Page 22: Web Sockets are not Just for Web Browsers

The Demo

AsyncMulticastWeb Browser

WPF Client

Page 23: Web Sockets are not Just for Web Browsers

Why Chris? Firewall benefits

Web Sockets supported by most firewalls since the underlying protocol is via HTTP

OSI Layer 5+ firewalls still support web sockets due to UPGRADE requests

Platform agnostic protocol Protocol defined by W3C and not a single vendor

Supports Java clients

Supports .NET clients

Supports Plethora of Platforms (Python, PHP, Perl)

Services can be built once No more separate solutions for client type restrictions

One service can support various clients

Page 24: Web Sockets are not Just for Web Browsers

Multiple Clients and One Service

WPF Client

WCF Service

Metro Client

Web BrowserClient

Page 25: Web Sockets are not Just for Web Browsers

Show me the code one last time!

Demonstrations One service

Windows 8 client

WPF Client

Web client walkthrough

Page 26: Web Sockets are not Just for Web Browsers

Code and Slides

• Git Hug: https://github.com/jixer/wcf-windows-8-web-sockets/ • My Blog:

http://www.bloggedbychris.com/2013/09/23/nwvdnug-web-sockets-presentation/

Page 27: Web Sockets are not Just for Web Browsers

PCSUG http://pcsug.org/

Meeting at Interface now

October 2nd, 2013: The Connected Systems Voyage - Charted and Uncharted Territories Chris Myers, President, PCSUG

Page 28: Web Sockets are not Just for Web Browsers

Questions?