Web Sockets are not
Just for Web Browsers
September 2013
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
What the Heck
are they?
Web Sockets
Overview
We got a problem
Dilemmas 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
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
Key Take-Aways
Is it request response? Nope. It‟s Full duplex.
More on this later…
What Else?
Solves world hunger!!!!
…
Well, not really, but it‟s still pretty awesome
We Got a Problem Here:
Request / Response Dilemma
Request: I need „XYZ‟ resource
Response: Here is „XYZ‟ resource
Client Server
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
Short Polling
Long Polling
I bet you have a question right about
now…
What are we ever to do????
Please… let me catch my breath
Don‟t fret. Let me back up a second and catch my breath…
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
Solution Overview
Full duplex!
Full duplex from a web brower???
This is awesome!
Full duplex!
However, I won‟t believe it until I see it
Show me the code!
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
You‟re probably wondering…
Wait a second Chris… You‟re telling me that I can use other applications other
than 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!
Show me the code again!
The Demo
Web Browser
WPF Client
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
Multiple Clients and One Service
WPF Client
WCF Service
Metro Client
Web Browser
Client
Show me the code one last time!
 Demonstrations
 One service
 Windows 8 client
 WPF Client
 Web client walkthrough
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/
PCSUG
 http://pcsug.org/
 Meeting at Interface now
 October 2nd, 2013: The Connected Systems Voyage - Charted and Uncharted
Territories
 Chris Myers, President, PCSUG
Questions?

Web Sockets are not Just for Web Browsers

  • 1.
    Web Sockets arenot Just for Web Browsers September 2013
  • 2.
    About Me  Iam 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
  • 3.
    What the Heck arethey? Web Sockets Overview We got a problem Dilemmas 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
  • 4.
    What are WebSockets?  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
  • 5.
    Key Take-Aways Is itrequest response? Nope. It‟s Full duplex. More on this later…
  • 6.
    What Else? Solves worldhunger!!!! … Well, not really, but it‟s still pretty awesome
  • 7.
    We Got aProblem Here: Request / Response Dilemma Request: I need „XYZ‟ resource Response: Here is „XYZ‟ resource Client Server
  • 8.
    JavaScript Solutions  Howdo 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
  • 9.
  • 10.
  • 11.
    I bet youhave a question right about now… What are we ever to do????
  • 12.
    Please… let mecatch my breath Don‟t fret. Let me back up a second and catch my breath…
  • 13.
    Web Sockets: TheSolution 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
  • 14.
  • 15.
    Full duplex! Full duplexfrom a web brower??? This is awesome!
  • 16.
    Full duplex! However, Iwon‟t believe it until I see it
  • 17.
  • 18.
    Web Sockets arenot 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
  • 19.
    You‟re probably wondering… Waita second Chris… You‟re telling me that I can use other applications other than web browsers?
  • 20.
    The Truth andNothing but the Truth Yes my friend. This is the magic of open source protocols. “How?”, you ask. I‟ll show you how!
  • 21.
    Show me thecode again!
  • 22.
  • 23.
    Why Chris?  Firewallbenefits  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
  • 24.
    Multiple Clients andOne Service WPF Client WCF Service Metro Client Web Browser Client
  • 25.
    Show me thecode one last time!  Demonstrations  One service  Windows 8 client  WPF Client  Web client walkthrough
  • 26.
    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/
  • 27.
    PCSUG  http://pcsug.org/  Meetingat Interface now  October 2nd, 2013: The Connected Systems Voyage - Charted and Uncharted Territories  Chris Myers, President, PCSUG
  • 28.