2015 14th Sunday WebSocket

Source: Internet
Author: User

Qingming season rain in succession, the road pedestrian desire rains, Jiewen restaurant where is? The Cowboy Points Heng Fa Chuen. Every time Ching Ming can not help but think of du Mu this poem to remember ancestors, at this time the first sentence to write the weather, the second sentence to write the character mood, the third sentence to write a solution, the fourth sentence to give a solution, popular.

Just looked at it. Websorket Related content:

1), WebSocket Introduction

WebSocket protocol is a new protocol for HTML5, which implements full-duplex communication between the browser and the server (Full-duplex). Only one-way communication can be achieved through HTTP in the browser, comet can simulate two-way communication to some extent, but the efficiency is low and the server needs better support. Sockets and Xmlsocket in Flash enable true two-way communication, and with Flex Ajax Bridge, you can use both of these features in JavaScript. It is foreseeable that if WebSocket is implemented in a browser, it will replace the above two technologies and be widely used. In the face of this situation, HTML5 defines the WebSocket protocol, which can save server resources and bandwidth better and achieve real-time communication. The WebSocket protocol is also implemented in JavaEE7. The HTML5 Web Sockets specification defines the Web Sockets API, which supports full-duplex communication with the remote host using the Web socket protocol. It introduces the WebSocket interface and defines a full-duplex communication channel that operates on the web through a single socket. The HTML5 Web sockets provides a Web connection efficiently and with minimal overhead. This greatly reduces unnecessary network traffic and latency compared to old polling or long polling (Comet), which often requires the use of push-real-time data to the client or even to simulate full-duplex connections by maintaining two HTTP connections. To connect to a remote endpoint from a Web client using HTML5 Web sockets, you create a new WebSocket instance and provide it with a URL to represent the remote endpoint you want to connect to. The specification defines the ws://and wss://modes to represent WebSocket and secure websocket connections, respectively. A websocket connection is established by upgrading to the Web socket protocol during the initial handshake phase of the HTTP protocol between the client and the server, which is still a TCP/IP connection at the bottom. Address of draft WebSocket HYBI 12: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-12, which can be used as an entrance to other drafts.

2), advantages

A), the server and the client exchange between the header information is very small, about 2 bytes;

b), the client and the server can actively transmit data to each other;

c), without frequency to create TCP requests and destroy requests, reduce the use of network bandwidth resources, but also save server resources;

3), WebSocket data Frame Introduction

A), draft version 00 to draft version 05, detailed can view the draft document, decoding code can see Netty Websocketframedecoder and Websocketframeencoder implementation;

b), draft version 06 to now the latest draft 17, Introduction see article: http://blog.csdn.net/fenglibing/article/details/6852497

4), WebSocket different versions of several handshake modes

A), no security key, the oldest WebSocket handshake protocol implementation (FLASH);

b), a back-end handshake with two security key request headers;

c), a back-end handshake with a secure key request header is implemented; see: http://blog.csdn.net/fenglibing/article/details/7100070

5), WebSocket can cross the firewall? WebSocket uses standard 80 and 443 ports, both of which are firewall-friendly protocols, and Web sockets uses the HTTP upgrade mechanism to upgrade to the Web socket protocol. The HTML5 WEB sockets has an HTTP-compatible handshake, so the HTTP server can share the default HTTP and HTTPS side (80 and 443) with the WebSocket server.

6), WEB sockets and proxy server interaction with the proxy server problem:

A), the HTTP proxy server may choose to close the stream or idle websocket connections, as they look as if they are trying to connect an HTTP server that does not respond;

b), the proxy server may buffer unencrypted HTTP responses, which will bring an unpredictable delay to the HTTP response stream;

c), unencrypted WebSocket connection (ws://) server, if there is a transparent proxy server in the middle, the connection may fail, or send the message will fail, and the encrypted websocket connection in the presence of transparent proxy server, the probability of success is relatively large; For more information about proxies see: http://www.infoq.com/cn/articles/Web-Sockets-Proxy-Servers

7), websocket through the browser itself, the implementation of the Web side is very simple, simply to make a simple first websocket components, and increase the OnOpen, OnMessage, OnClose and other events processing can be.

Part excerpt: http://blog.csdn.net/fenglibing/article/details/7108982

2015 14th Sunday WebSocket

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.