itcamp 2011 - florin cardasim - duplex communications with wcf and azure

Post on 13-May-2015

1.102 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

IT Camp 2011

• Thanks for coming!

• ITCamp is made possible by our sponsors:

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Duplex Communications with WCF and Azure

Florin Cardașim, software developer

RomSoft Iași, www.rms.ro

caf@rms.ro | twitter.com/cardasim

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Session agenda

• Enterprise duplex. Non-browser clients

– WCF duplex bindings, router service

– Windows Azure Service Bus

• Web duplex. Browser clients

– Simple polling, comet/long polling

– WebSockets

• Q&A

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

ENTERPRISE DUPLEX

Non-browser clients

- WCF duplex bindings, router service

- Windows Azure Service Bus

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Full duplex using WCF NetTcpBinding

Event consumer

Event publisher

Publisher requires public IP Custom ports open in firewall

Full duplex TCP

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

“Full duplex” using WCF WSDualHttpBinding

Event consumer

Event publisher

Network address translation makes connection back

impossible

Duplex HTTP

NAT

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

“Full duplex” using WCF WSHttpBinding

Event consumer

Event publisher

Publisher and consumers require public IP That’s fine, BUT we want the servers INSIDE the enterprise

Dual HTTP

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

WCF Router Service

Event consumer

Event publisher

Firewall and NAT friendly Routers have protocol bridging, failover etc Not bad, but quite crowded. Can you do better?

Dual HTTP TCP TCP

Router Service Router Service

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Windows Azure Service Bus

Event consumer

Event publisher

Relay Service

sb://itcampnamespace.servicebus.windows.net/publisher

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

DEMO

Connecting the enterprises via:

-NetTcpBinding, WsDualHttpBinding

-RouterService, NetTcpBinding, WsDualHttpBinding

-Service Bus, NetEventRelayBinding

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Enterprise duplex: conclusions

• Direct TCP is best IF available • public endpoint , open ports in firewall

• Duplex HTTP is an alternative • public IP both publisher and consumer, port 80

• Router Service bridges the enterprises • flexible, but quite complicated deployment

• Azure Service Bus • very flexible & powerful; requires careful planning

because each connection costs money

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

WEB DUPLEX

Browser clients

- Simple polling, comet/long polling

- WebSockets

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Http polling

• Wasted resources, many requests return no data

• Frequent polling means higher load on the server

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Comet/long polling

• Bandwidth: small payload, large http headers overhead

• Scalability: pressure on memory, bandwidth, threads/processes

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

DEMO

An open source, WCF based, long polling server implementation:

http://laharsub.codeplex.com/

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Html5 WebSockets

• Full duplex, bidirectional

• Single TCP socket

• Standard ports: http/80, https/443

• Bandwidth savings

• More scalable than Comet

• Nice programming model

• In&outside of browser

Server

Client

Drafts: -IETF WebSockets Protocol

-W3C WebSockets API

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Html5/websockets: server

• Socket.IO (Java, node.js)

• Jetty (Java)

• Ruby/EventMachine

• Python/Twisted

• WCF websocket prototype

• … others

• Socket.IO Fallbacks – Adobe Flash Socket

– AJAX Long Polling

– AJAX Multipart Streaming

– Forever iFrame

– JSONP Polling

• http://socket.io/

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Html5/websockets: server

• Test browser support: http://websocket.org/echo.html

• Microsoft is still experimenting

• http://html5labs.com

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

DEMO

Some WebSockets in action:

http://kaazing.me

http://retrospectiveapp.heroku.com

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

DEMO

Using the WCF WebSockets prototype from http://html5labs.com

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Q&A

@itcampro / #itcampro Premium conference on Microsoft’s Dev and ITPro technologies

Don’t forget!

Get your free Azure pass!

• 30+15 days, no CC req’d

– http://bit.ly/ITCAMP11

– Promo code: ITCAMP11

We want your feedback!

• Win a WP7 smartphone

– Fill in your feedback forms

– Raffle: end of the day

top related