IAC 2024 - IA Fast Track to Search Focused AI Solutions
ITCamp 2011 - Florin Cardasim - Duplex Communications with WCF and Azure
1. IT Camp 2011
• Thanks for coming!
• ITCamp is made possible by our sponsors:
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
2. Duplex Communications
with WCF and Azure
Florin Cardașim, software developer
RomSoft Iași, www.rms.ro
caf@rms.ro | twitter.com/cardasim
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
3. 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
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
4. Non-browser clients
- WCF duplex bindings, router service
- Windows Azure Service Bus
ENTERPRISE DUPLEX
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
5. Full duplex using WCF NetTcpBinding
Event
Full duplex TCP publisher
Event
consumer
Publisher requires public IP
Custom ports open in firewall
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
6. “Full duplex” using WCF WSDualHttpBinding
Event
N publisher
Duplex HTTP
A
Event T
consumer
Network address translation
makes connection back
impossible
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
7. “Full duplex” using WCF WSHttpBinding
Event
publisher
Dual HTTP
Event
consumer
Publisher and consumers
require public IP
That’s fine, BUT we want the
servers INSIDE the enterprise
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
8. WCF Router Service
Router Service Router Service
Dual HTTP TCP
TCP
Event
Event publisher
consumer
Firewall and NAT friendly
Routers have protocol bridging,
failover etc
Not bad, but quite crowded.
Can you do better?
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
9. Windows Azure Service Bus
sb://itcampnamespace.servicebus.windows.net/publisher
Relay Service
Event Event
consumer publisher
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
10. Connecting the enterprises via:
-NetTcpBinding, WsDualHttpBinding
-RouterService, NetTcpBinding, WsDualHttpBinding
-Service Bus, NetEventRelayBinding
DEMO
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
11. 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
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
12. Browser clients
- Simple polling, comet/long polling
- WebSockets
WEB DUPLEX
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
13. Http polling
• Wasted resources, many requests return no data
• Frequent polling means higher load on the server
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
14. Comet/long polling
• Bandwidth: small payload, large http headers
overhead
• Scalability: pressure on memory, bandwidth,
threads/processes
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
15. An open source, WCF based, long polling server implementation:
http://laharsub.codeplex.com/
DEMO
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
16. Html5 WebSockets
• Full duplex, bidirectional
Server
• Single TCP socket
• Standard ports: http/80,
https/443
• Bandwidth savings Client
• More scalable than Comet
• Nice programming model Drafts:
• In&outside of browser -IETF WebSockets Protocol
-W3C WebSockets API
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
18. Html5/websockets: server
• Test browser support: http://websocket.org/echo.html
• Microsoft is still experimenting
• http://html5labs.com
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
19. Some WebSockets in action:
http://kaazing.me
http://retrospectiveapp.heroku.com
DEMO
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
20. Using the WCF WebSockets prototype from http://html5labs.com
DEMO
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
21. References
• channel9.msdn.com/Learn/Courses/Azure/ServiceBus
• en.wikipedia.org/wiki/Comet_%28programming%29
• html5rocks.com/tutorials/websockets/basics
• websocket.org
• pusher.com
• kaazing.com
• live.visitmix.com/MIX11?q=web+sockets
• paulbatum.com
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
22. Q&A
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
23. Don’t forget!
Get your free Azure pass! We want your feedback!
• 30+15 days, no CC req’d • Win a WP7 smartphone
– http://bit.ly/ITCAMP11 – Fill in your feedback forms
– Promo code: ITCAMP11 – Raffle: end of the day
Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro