â [AWS] ELBã§HTTPãªã¹ãã¼ã ã¨WebSocketã¯ä½¿ããªã ELBã使ã£ã¦ãã¦ãWebSocketã使ããã¨ããã¨ãã«ãæåã®ãã³ãã·ã§ã¤ã¯ãä¸æããããªãã¨ããåé¡ã«ééããã ãã¹ãããããã«ãnode.jpã®ããã¥ã¡ã³ããããhttp.ClientReqestã«ãããµã³ãã«ã使ã£ã¦ã¿ããããã®Event: 'Upgrade'ã®ã¨ããã«ãããµã³ãã«ã³ã¼ããè¥å¹²æ¹é ãã¦ä¸è¨ã®ãããªã³ã¼ããç¨æããã var http = require('http'); var net = require('net'); // Create an HTTP server var srv = http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('
2010å¹´12æ04æ¥ ãªã¢ã«ã¿ã¤ã WEBã¨ã ãä½ããã¨ãã¦ããããã¦ãã¦ãã¢ããªé¨åï¼railsã¨ãï¼ã¨ãªã¢ã«ã¿ã¤ã å¦çé¨åï¼cometãã¼ã¹ããããã¯websocketï¼ã¨ã®æ¯ãåãããªãã¨ãã§ããªããã ã¤ã¾ãï¼ï¼çªãã¼ãï¼ã¤ã§ãã¹ã¦åãããã£ã¦ãã¨ãã§ããªããã調ã¹ã¦ãã®ã§ãã®ç¾æç¹ã§ã®èªåç¨ã¡ã¢ã ã¦ãããããã¼ãï¼ã¤ä½¿ããã®ã§ããã°shooting_starãã¼ã¹ã§ä¸å¿ã²ã¨éãåãç¶æ ã«ã¯ãªã£ã¦ããã ãã©ããã¼ãï¼ã¤ä½¿ã£ã¡ãã£ã¦ããããSSLåã§ããªãã¨ããã®ãä»ã®èª²é¡ã ã§ããã ãæãã¢ãã§ãã¾ããã¨ããå ´åãæ¹æ³ã¨ãã¦ã¯ï¼ã¤ã â nginxç¨ã®ãã©ã°ã¤ã³ã§æ¯ãåãã âãªã¢ã«ã¿ã¤ã å¦çã®é¨åãç¬èªå®è£ ã«ãªã£ã¦ãã¦ï¼æ©ã¾ããã ããããã¯ãã£ã±websocketã ããã¨ããæ°ããã¤ã¤ã â haproxyã§ãwebsocketã®ãªã¯ã¨ã¹ããæ¯ãåãã âããã
WebSocketã¨proxyå¨ãã®è©±ã«ã¤ãã¦ç°¡åã«ã ã¡ãã£ã¨è¿½ããããªãæãããã®ã§ãããç¥ã£ã¦ããæ¹ãããã£ãããã¾ããããã³ã¡ã³ãçã§æãã¦ããã ããã¨å¹¸ãã§ãã 以ä¸ãhixie-76ã¨ãietf-00ã¨ãè¨ãã®ã¯ãWebSocketã®ãã¼ã¸ã§ã³ã表ãã¾ãã(ãªããæ£å¼ãªå称ã§ã¯ããã¾ãããhybiã®ãã¼ã¸ã§ã³ã«åºã¥ãã¦ã便å®çã«ç§ãããå¼ãã§ããã ãã§ã) hixie-76(âietf-00)ã®ã¿ãç¹ãããªãå ´åããã handshakeã«æ¼ãã¦ãcontent-lengthç¡ãã§bodyã«8byteæååãä»å ãããã (ã¾ããbodyã®8byteã¯å¥packetã§éä»ããããä¸å³) browser â (handshakeã®headeré¨å) â> server browser â (handshakeã®bodyé¨å) â> server browser prox
pywebsocketã¨ããPython製ã®websocketãå©ç¨ããããã®Apacheã¢ã¸ã¥ã¼ã«ããããããã®ã§ãã¡ãã£ã¨ã ãè¦ã¦ã¿ã¾ãããã¡ãªã¿ã«ãã®ã¨ã³ããªã¯Pythonã¨ã¯ãã¾ãé¢ä¿ãããã¾ãããèå³ãæã£ããã£ããã¯ãç¾ç¶ã®Apacheã§C10Kãã©ããã£ã¦è§£æ±ºãã¦websocketãå®è£ ããã®ã ããã¨ãããã¨ã§ããçµè«ã¯æ®å¿µãªããåã«Apacheã§websocketãå©ç¨ããããã ãã®ãã®ã§ããããã ãç¾ç¶ã®ã¤ã³ãã©ã§ã¡ãã£ã¨ã ãå®ç¨çã«websocketãéã¹ãã®ã¯ããã¯ããã§ãã°ããããã¨ã§ããåãgolangã§æ¸ãããµã³ãã«ããããã¯golangã¯ã¾ã å®ç°å¢ã§ä½¿ãã代ç©ã§ã¯ãªããã Apacheã¯ã¹ã¬ããã¢ãã«ã§åãã¾ããä¸ã¤ã®ãªã¯ã¨ã¹ããä¸ã¤ã®ã¹ã¬ãããå æãã¾ããWebSocketèªä½ã¯ãAJAXã«ããå®æçãªãã¼ãªã³ã°ãcometã«ãããã³ã°ãã¼ãªã³ã°ããã¯ãªã¼ã
Node.js 㧠socket.io 使ã£ã¦ã¦ã§ããã£ããä½ã£ã¦éã¶ï¼ ã¨ããã£ã¦ãã¨ããã®ãã¡ä½ã£ãã¢ããªãèªå® ãµã¼ãã¨ãã§å ¬éããããªãã®ã人ã®ä¸ã®å¸¸ã¨ãããã®ã§ããã ã¨ãã«èããã«èªå® ãµã¼ãã§ä½ã£ãã¢ããªãåãããã¨ããã¨ã ãNode.js ã§ä½ã£ãã¢ããªããã¼ã3000çªã§åããã¦ã¼ãããã³ããµã¼ãã¨ã㦠Apache ã nginx ãç½®ãã°è¯ããã¼ã ã£ã¦æãã§ä¸ã®å³ã®ãããªæ§æã«ãªãã¨æãã¾ãã¼ãã (ããããã¤ãã³ãã«ã¼ãã売ãã® Node.js ã®ããã³ããµã¼ãã Apache ã£ã¦ã©ããªã®ï¼ã£ã¦ã®ã¯ç½®ãã¨ãã¦ã) ãµã¨æ°ã¥ããã¯ã©ã¤ã¢ã³ãããã® WebSocket ãå±ãã¦ããï¼ ã¯ãã対å¿ãã¦ãªããã§ããããApache ã nginx ããWebSocket ã®ãããã·ã¯ã ä»æ¹ãªãã®ã§ç¡çç¢çåãããã¨ããã¨ãNode.js ã¢ããªãåãã¦ããã¼ããéããã¨
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}