Router と WebSocket
Upcoming SlideShare
Loading in...5
×
 

Router と WebSocket

on

  • 2,934 views

第2回CloudFoundry輪読会講演資料

第2回CloudFoundry輪読会講演資料

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

Statistics

Views

Total Views
2,934
Views on SlideShare
2,922
Embed Views
12

Actions

Likes
3
Downloads
31
Comments
0

2 Embeds 12

https://twitter.com 7
http://a0.twimg.com 5

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \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 Router と WebSocket Presentation Transcript

  • 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 Upgrade: websocketResponse Header (server => client) HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Upgrade HTTP WebSocket
  • HTTP Compatible• VPN • FW, Proxy • HTTP/1.1 • • Web VPN
  • http://www.ericom.com/html5_client_vmware_view.asp http://www.publickey1.jp/blog/11/webhtml5.html
  • CloudFoundry WebSocket orz• why? • nginx 2 • router HTTP/1.1 rails sinatra nginx router node.js DEA
  • • 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
  • WebSocket nginx • Request HTTP (502) • tcp_proxy Patch •https://github.com/yaoweibin/nginx_tcp_proxy_module
  • 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; }}
  • WebSocket router• HTTP Request/Response HTTP• WebSocket Frames• HTTP
  • 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
  • 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
  • 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
  • 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
  • Demo (echo server)
  • • proof of concept• production• zip, ssl NG• WebSocketConnection• :)
  • Thank you!!http://twitter.com/komasshu