Router WebSocket      2011/11/17(thu)    2 CloudFoundry
•                             (@komasshu)•   WebSocket•   Google API Expert (HTML5)•   Microsoft Valuable Professional (IE)
CloudFoundryWebSocket                 ...
WebSocket• HTML5   API/Protocol• Web •
• Web(port=80)   VPN •   SSL-VPN
Handshake
Handshake
HandshakeFrames
point : UpgradeRequest Header (client => server)          GET /chat HTTP/1.1          Host: server.example.com          Up...
HTTP Compatible•           VPN    • FW, Proxy        •         HTTP/1.1    •        •   Web        VPN
http://www.ericom.com/html5_client_vmware_view.asp                                                     http://www.publicke...
CloudFoundry  WebSocket                   orz• why? • nginx                  2 • router      HTTP/1.1                     ...
• nginx • zip      Access log        HTTPS• router • URL routing                                    URL routing           ...
WebSocket                     nginx    • Request     HTTP                  (502)      •   tcp_proxy Patch      •https://gi...
nginx.conftcp {   upstream vcap_router {     server unix:/tmp/router.sock;# server 127.0.0.1:2222;# check interval=3000 ri...
WebSocket                router•   HTTP Request/Response     HTTP•   WebSocket       Frames•                           HTTP
dialog of router.rb       request  Header                                    router     request/sec         Router        ...
WebSocketUpgrade: websocket                      proof of conceptWebsocketConnection                                   rou...
client_connection.rbdef on_headers_complete(headers)  ....   # [kom] Check connection mode(websocket or not)   @is_websock...
websocket_connection.rbmodule WebsocketConnection def initialize client, header, droplet  @client, @header, @droplet = cli...
Demo (echo server)
•             proof of concept•                production• zip, ssl NG• WebSocketConnection•                        :)
Thank you!!http://twitter.com/komasshu
Router と WebSocket
Router と WebSocket
Router と WebSocket
Upcoming SlideShare
Loading in...5
×

Router と WebSocket

2,637

Published on

第2回CloudFoundry輪読会講演資料

cloud foundryのrouterとかを弄って、WebSocket動くようにしてみましたよ!!というお話

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,637
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
34
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Router と WebSocket

    1. 1. Router WebSocket 2011/11/17(thu) 2 CloudFoundry
    2. 2. • (@komasshu)• WebSocket• Google API Expert (HTML5)• Microsoft Valuable Professional (IE)
    3. 3. CloudFoundryWebSocket ...
    4. 4. WebSocket• HTML5 API/Protocol• Web •
    5. 5. • Web(port=80) VPN • SSL-VPN
    6. 6. Handshake
    7. 7. Handshake
    8. 8. HandshakeFrames
    9. 9. point : UpgradeRequest Header (client => server) GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocketResponse Header (server => client) HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Upgrade HTTP WebSocket
    10. 10. HTTP Compatible• VPN • FW, Proxy • HTTP/1.1 • • Web VPN
    11. 11. http://www.ericom.com/html5_client_vmware_view.asp http://www.publickey1.jp/blog/11/webhtml5.html
    12. 12. CloudFoundry WebSocket orz• why? • nginx 2 • router HTTP/1.1 rails sinatra nginx router node.js DEA
    13. 13. • nginx • zip Access log HTTPS• router • URL routing URL routing unix domain tcp socket socket rails (tcp socket ) 80/443 sinatra nginx router node.js DEA
    14. 14. WebSocket nginx • Request HTTP (502) • tcp_proxy Patch •https://github.com/yaoweibin/nginx_tcp_proxy_module
    15. 15. nginx.conftcp { upstream vcap_router { server unix:/tmp/router.sock;# server 127.0.0.1:2222;# check interval=3000 rise=2 fall=5 timeout=1000; } tcp_nodelay off; server { listen 80; server_name _; proxy_read_timeout 200000; proxy_send_timeout 200000; proxy_pass vcap_router; }}
    16. 16. WebSocket router• HTTP Request/Response HTTP• WebSocket Frames• HTTP
    17. 17. dialog of router.rb request Header router request/sec Router on_headers _complete() unix module module node.jsnginx domain TCP socket socket ClientConnection AppConnection on_headers _complete() response Header response latency
    18. 18. WebSocketUpgrade: websocket proof of conceptWebsocketConnection router module TCP socket node.js on_headers AppConnection _complete() on_headers unix module _complete() nginx domain socket ClientConnection module WebsocketConne TCP socket node.js ction WS
    19. 19. client_connection.rbdef on_headers_complete(headers) .... # [kom] Check connection mode(websocket or not) @is_websocket = (headers[UPGRADE_HEADER] == WEBSOCKET) ? true : false Router.log.info "@is_websocket : #{@is_websocket}" .... if (@is_websocket) host, port = @droplet[:host], @droplet[:port] @bound_app_conn = EM.connect(host, port, WebsocketConnection, self,@headers, @droplet) return end ....end
    20. 20. websocket_connection.rbmodule WebsocketConnection def initialize client, header, droplet @client, @header, @droplet = client, header, droplet end def connection_completed send_data(@header) end def receive_data(data) @client.send_data(data) end def terminate end orzend
    21. 21. Demo (echo server)
    22. 22. • proof of concept• production• zip, ssl NG• WebSocketConnection• :)
    23. 23. Thank you!!http://twitter.com/komasshu
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×