ebSocket å¯è½è¿å
¥æç§åæ»ä¸æ´»çç¶æãè¿å®é
ä¸ä¹æ¯åæç½ç»ä¸ççä¸äºç¼ºé·æ§è®¾è®¡ãWebSocket é¿è¿æ¥è½ç¶è§£å³äºæå¡å¨å客æ·ç«¯ä¸¤è¾¹çé®é¢ï¼ä½åç¹çæ¯ç½ç»åºç¨é¤äºæå¡å¨å客æ·ç«¯ä¹å¤ï¼å¦ä¸ä¸ªå·¨å¤§çåå¨æ¯ä¸é´çç½ç»é¾è·¯ãä¸ä¸ª HTTP/WebSocket è¿æ¥å¾å¾è¦ç»è¿æ æ°çè·¯ç±ï¼é²ç«å¢ãä½ ä»¥ä¸ºä½ çæ°æ®æ¯å¨ä¸ä¸ªâè¿æ¥âä¸åéçï¼å®é
ä¸å®è¦è·¨è¶åå±±ä¸æ°´ï¼ç»è¿æ æ°æ¬¡è½¬åï¼è¿æ»¤ï¼æè½æç»æµè¾¾ç»ç¹ãå¨è¿è¿ç¨ä¸ï¼ä¸é´èç¹çå¤çæ¹æ³å¾å¯è½ä¼è®©ä½ ææ³ä¸å°ã
æ¯å¦è¯´ï¼è¿äºåç¹çä¸é´èç¹å¯è½ä¼è®¤ä¸ºä¸ä»½è¿æ¥å¨ä¸æ®µæ¶é´å
没ææ°æ®åéå°±çäºå¤±æï¼å®ä»¬ä¼èªä½ä¸»å¼ çåæè¿äºè¿æ¥ãå¨è¿ç§æ
åµä¸ï¼ä¸è®ºæå¡å¨è¿æ¯å®¢æ·ç«¯é½ä¸ä¼æ¶å°ä»»ä½æ示ï¼å®ä»¬åªä¼ä¸å¢æ
æ¿ç以为彼æ¤é´ç红线è¿å¨ï¼å¾å³å°ä¸è¾¹åä¸è¾¹å°åéæµè¾¾ä¸äºå½¼å²¸çä¿¡æ¯ãè计ç®æºç½ç»åè®®æ çå®ç°ä¸åä¼æä¸å±å¥ä¸å±çç¼åï¼é¤é填满è¿äºç¼åï¼ä½ çç¨åºæ ¹æ¬ä¸ä¼åç°ä»»ä½é误ãè¿æ ·ï¼æ¬æ¥ä¸ä¸ªç¾å¥½ç WebSocket é¿è¿æ¥ï¼å°±å¯è½å¨æ¯«ä¸ç¥æ
çæ
åµä¸è¿å
¥äºåæ»ä¸æ´»ç¶æã
è解å³æ¹æ¡ï¼å°±æ¯è®©æå¡å¨å客æ·ç«¯è½å¤åé Ping/Pong Frameï¼RFC 6455 - The WebSocket Protocolï¼ãè¿ç§ Frame æ¯ä¸ç§ç¹æ®çæ°æ®å
ï¼å®åªå
å«ä¸äºå
æ°æ®èä¸éè¦çæ£ç Data Payloadï¼å¯ä»¥å¨ä¸å½±å Application çæ
åµä¸ç»´æä½ä¸é´ç½ç»çè¿æ¥ç¶æã
温馨提示:答案为网友推荐,仅供参考