WO2013102335A1 - 一种网关握手、通信方法、网关及Web通信系统 - Google Patents

一种网关握手、通信方法、网关及Web通信系统 Download PDF

Info

Publication number
WO2013102335A1
WO2013102335A1 PCT/CN2012/075780 CN2012075780W WO2013102335A1 WO 2013102335 A1 WO2013102335 A1 WO 2013102335A1 CN 2012075780 W CN2012075780 W CN 2012075780W WO 2013102335 A1 WO2013102335 A1 WO 2013102335A1
Authority
WO
WIPO (PCT)
Prior art keywords
web browser
gateway
protocol
address information
web
Prior art date
Application number
PCT/CN2012/075780
Other languages
English (en)
French (fr)
Inventor
关国锋
朱建峰
范家星
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2013102335A1 publication Critical patent/WO2013102335A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services

Definitions

  • Gateway handshake communication method, gateway and web communication system
  • the present invention relates to the field of communications, and in particular, to a gateway handshake, a communication method, a gateway, and a Web communication system.
  • the relay server acts as a communication intermediary or gateway, between the supporting web browsers or the Web.
  • HTTP-based technology to communicate, such as: Polling or Comet, where Polling can only support Half-duplex communication, while Comet uses two connections for upstream and downstream data to simulate full-duplex communication, which consumes twice as many Web application server resources, is inefficient, in short, based on the HTTP protocol.
  • the technology is not designed for real-time full-duplex communication.
  • a primary object of the present invention is to provide a gateway handshake, a communication method, a gateway, and a web system to support direct full-duplex operation between web browsers, or between a web browser and a back-end server through a gateway. Communication to enable real-time data interaction.
  • a method for gateway handshake including: Receiving, by the gateway, a handshake message of the web browser, where the handshake message carries a protocol upgrade request and address information of the web browser;
  • the gateway changes the application layer protocol between the web browser and the gateway from a hypertext transfer protocol HTTP to a web socket protocol Websocket according to the protocol upgrade request, so that the web browser and the web browser Establishing a Websocket data transmission channel between the gateways;
  • the gateway saves the address information of the web browser to a storage medium.
  • a communication method of a gateway comprising:
  • the gateway receives the data packet sent by the first web browser to the second web browser, where the data packet carries the application data and address information of the second web browser;
  • the gateway queries the storage medium to find a web socket protocol Websocket data transmission channel that matches the address information of the second web browser;
  • the gateway forwards the application data to the second web browser through the found Websocket data transmission channel.
  • a communication method of a gateway comprising:
  • the gateway receives a data packet sent by the web browser to the backend server, where the data packet carries application data and address information of the backend server;
  • the gateway establishes a data transmission channel based on the transmission control protocol TCP connection between the gateway and the back-end server according to the address information of the back-end server, and saves the address information of the back-end server to the storage.
  • TCP transmission control protocol
  • the gateway sends the application data to the backend server through the established TCP connection-based data transmission channel.
  • a gateway includes: a protocol engine module and a storage medium, where the protocol engine module includes: a request receiving unit, configured to receive a handshake message of a web browser, where the handshake message carries a protocol upgrade request and the web browser Address information;
  • a protocol conversion unit configured to change, according to the protocol upgrade request, an application layer protocol between the web browser and the gateway, from a hypertext transfer protocol HTTP to a web socket protocol
  • a gateway includes: a receiving module, a forwarding module, and a storage medium; The receiving module is configured to receive a data packet sent by the first web browser to the second web browser, where the data packet carries application data and address information of the second web browser;
  • the storage medium stores address information of a web browser that establishes a web socket protocol Websocket data channel with the gateway;
  • the forwarding module is configured to query the storage medium, find a Websocket data transmission channel that matches the address information of the second Web browser, and forward the application data to the Websocket data transmission channel that is found to The second web browser.
  • a gateway comprising: a receiving module, another TCP protocol transceiver module, and a storage medium; the receiving module is configured to receive a data packet sent by the web browser to the backend server, where the data packet carries the application data and the Address information of the server;
  • the other TCP protocol transceiver module is configured to establish, according to address information of the backend server, a data transmission channel based on a TCP connection between the gateway and the backend server, and establish the TCP-based connection
  • the data transmission channel sends the application data to the backend server
  • the other TCP protocol transceiver module is further configured to save the address information of the backend server to the storage medium.
  • a web communication system comprising: a gateway, a backend server;
  • the gateway includes: a protocol engine module, a receiving module, a forwarding module, and a storage medium; and the protocol engine module includes:
  • a request receiving unit configured to receive a handshake message of the first web browser, the second web browser, and the N Web browser, where the handshake message carries a protocol upgrade request and the first web browser, Address information of the web browser or the Nth web browser, where N is a natural number;
  • a protocol conversion unit configured to respectively apply an application layer transmission protocol between the first web browser, the second web browser, and/or the Nth web browser and the gateway according to the protocol upgrade request Changing from the hypertext transfer protocol HTTP to the web socket protocol Websocket, so that the first web browser, the second web browser and/or the Nth web browser and the gateway establish a Websocket data transmission aisle;
  • the receiving module is configured to receive a data packet sent by the first web browser to a target node, where the data packet carries application data and address information of the target node;
  • the forwarding module is configured to: when the target node is the second web browser, query the storage medium, find a Websocket data transmission channel that matches the address information of the second web browser, and pass the The found Websocket data transmission channel forwards the application data to the second web browser.
  • a Websocket connection can be established between the gateway and the web browser, that is, a full-duplex Websocket data transmission channel to support the web browser, or the web browser and the back end in the local area network.
  • a Websocket connection can be established between the gateway and the web browser, that is, a full-duplex Websocket data transmission channel to support the web browser, or the web browser and the back end in the local area network.
  • efficient full-duplex communication through the gateway to interact with data in real time.
  • FIG. 1 is a flowchart of a method for a gateway handshake according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic diagram of address information of a web browser carried by a gateway in a gateway handshake method according to the first embodiment of the present invention for acquiring and storing a handshake message;
  • FIG. 3 is a flowchart of a method for communication between web browsers according to a second embodiment of the present invention
  • FIG. 4 is a flow chart of a method for communicating between a web browser and a backend server according to Embodiment 3 of the present invention
  • FIG. 5 is a schematic diagram of a gateway according to Embodiment 4 of the present invention.
  • FIG. 6 is a schematic diagram of a gateway according to Embodiment 5 of the present invention.
  • FIG. 7 is a schematic diagram of a gateway according to Embodiment 6 of the present invention.
  • FIG. 8 is a schematic diagram of a web communication system according to Embodiment 7 of the present invention.
  • DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The technical solutions in the embodiments of the present invention will be clarified in the following with reference to the accompanying drawings in the embodiments of the present invention.
  • BRIEF DESCRIPTION OF THE DRAWINGS It is apparent that the described embodiments are only a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
  • Hypertext Transfer Protocol HTTP
  • Web World Wide Web
  • the HTTP protocol is the most widely used network protocol on the Internet.
  • the HTTP protocol defines the standards for request and response from Web clients and Web application servers. All Web files must comply with this standard.
  • the information exchange process of the Web client/application server request response mechanism based on the HTTP protocol includes four steps:
  • the web application server After processing the web client request, the web application server sends a response message to the web client.
  • the content of the response message includes the version of the message protocol, success or error encoding plus the web application server information, entity element. Information and possible physical content;
  • Both the Web client and the Web application server can end the TCP/IP session by closing the socket.
  • Websocket is a new protocol defined in HTML5, which supports efficient communication between full-duplex and full-duplex communication between Web client and Web application server through a Websocket connection. Websocket has an HTTP-compatible handshake mechanism that can share the default HTTP and HTTPS ports (80 and 443).
  • the communication mechanism of Websocket is as follows:
  • the web client can send the handshake message to the web application server, and the web client
  • the HTTP protocol between the web application server is promoted to the Websocket protocol to establish a Websocket connection.
  • the web client (example.com) sends an HTTP Upgrade request to the web application server (server.example.com).
  • Host is the Web application server host
  • Upgrade is the protocol upgrade type
  • Connection is the connection type
  • Key is the security authentication key
  • Origin is the request source
  • Protocol is the optional sub-protocol name
  • the web application server accepts the HTTP Upgrade request and returns a response message to the web client, such as:
  • 8jKS'y: G*Co, Wxa- where 101 is the HTTP response status code (101: the client asks the server to translate the HTTP protocol version according to the request), Origin must be equal to the source of the HTTP Upgrade request, and Location must be equal to the address of the HTTP Upgrade request.
  • Protocol must contain the sub-protocol name of the HTTP Upgrade request, "8jKS, y:G*Co, Wxa-,, for 16 bytes of data constructed by the Key in the HTTP Upgrade request, MD5 encryption to get a 16-byte Value
  • Embodiment 1 After the Websocket connection is established, the Websocket data frame can be transferred back and forth between the Web client and the Web application server in full-duplex mode.
  • Embodiment 1
  • FIG. 1 is a flowchart of a method for a gateway handshake according to Embodiment 1 of the present invention.
  • the method for the gateway handshake in the first embodiment of the present invention includes:
  • the gateway receives a handshake message of the webpage web browser, where the handshake message carries a protocol upgrade request and address information of the web browser.
  • protocol upgrade request is generally an HTTP GET request, and the specific example may be as follows:
  • the address information of the web browser may be carried in the HTTP GET request by adding a cell.
  • the gateway according to the protocol upgrade request, changing an application layer protocol between the web browser and the gateway from a hypertext transfer protocol HTTP to a web socket protocol Websocket, so that the web browser Establishing a Websocket data transmission channel with the gateway. It should be noted that, after the gateway upgrades the HTTP protocol to the Websocket protocol, the gateway may also return a response message to the web browser.
  • the response message may be a message that is sent by the WebSocket gateway to the protocol upgrade request, and an example of the response message may be as follows:
  • the gateway saves address information of the web browser to a storage medium.
  • the storage medium may be a non-volatile persistent storage medium.
  • the gateway may establish an initial forwarding table in the storage medium, and the web browser read during the handshake Address information, and updated to the forwarding table.
  • S102 and S103 in this embodiment is not used to limit the present invention, S102 and S103 may be parallel processing, or S103 may be processed before S102.
  • the gateway can establish a Websocket connection with each web browser by shaking hands with a web browser having communication requirements, and obtain and save address information of each web browser at the same time, and the gateway can be based on any one of the webs.
  • the browser's address information find the gateway and the Web browser's Websocket connection, in order to further send data to the browser or back-end server.
  • the address information of the web browser may include: a user group identifier ID, a user ID, a network protocol IP address, and a port, where the user group ID is the web browser
  • the communication group identifier specifically, the communication group may be similar to the group concept in Tencent's instant chat tool QQ, the user ID is the identity of the web browser, and the web browser of different user IDs Communication with each other is possible only when the user group IDs are the same.
  • the method further includes:
  • S104 The gateway closes the Websocket data transmission channel between the web browser and the gateway.
  • the web browser and the web browser may be closed.
  • the Websocket data transmission channel between the gateways, in particular, the TCP connection between the Web browser and the gateway is closed, which is beneficial to save network resources.
  • the method for the gateway handshake according to the first embodiment is as shown in FIG. 3.
  • the second embodiment of the present invention provides a gateway communication method, which includes the following steps:
  • the gateway receives a data packet sent by the first web browser to the second web browser, where the data packet carries application data and address information of the second web browser.
  • the first web browser acts as a communication initiation node
  • the second browser acts as a communication target node
  • the application data in the data packet is constructed and encapsulated according to a data format specified by the Websocket protocol, and the application data may be transmitted in the form of a data frame.
  • the address information of the second web browser is generally encapsulated into a header file and then transmitted, and the gateway parses the header file to obtain the second web browser.
  • Address information Those skilled in the art should know that OSI (Open System Interconnection) logically divides the network into seven layers, namely: physical layer, data link layer, network layer, transport layer, session Layer, presentation layer, application layer, OSI seven-layer model is a framework design method. The main purpose of building a seven-layer model is to solve the compatibility problems encountered when heterogeneous network interconnections to help different types of communication. The node implements data transmission.
  • OSI Open System Interconnection
  • the gateway analyzes the data packet, specifically In other words, a seven-layer analysis of the header file of the packet can be performed to obtain the address information of the target node. According to the address information of the target node, you can also determine the destination node for the Web browser, or back-end servers within the LAN.
  • the gateway queries the storage medium, and finds a Websocket data transmission channel that matches the address information of the second web browser.
  • the gateway compares the address information of the second web browser with the address information of each web browser stored in the storage medium of the gateway, for example, by querying a forwarding table, and finding the first The Websocket data transmission channel where the web browser is located.
  • the gateway by using the found Websocket data transmission channel, the number of applications Forwarded to the second web browser.
  • the second web browser may also return a delivery confirmation message to the first web browser through the gateway.
  • the gateway when communicating between two web browsers, performs the address information of the second web browser as the communication destination node and the address information of each web browser previously stored in the storage medium.
  • the comparison can find the Websocket data transmission channel where the second web browser is located, and realize the real-time full-duplex efficient communication between the two web browsers based on the Websocket protocol through the Websocket data transmission channel.
  • the address information of the second web browser may include: a user group ID, a user ID, an IP address, and a port.
  • the third embodiment of the present invention further provides a gateway communication method, including the following steps:
  • the gateway receives a data packet sent by the web browser to the backend server, where the data packet carries application data and address information of the backend server.
  • the back-end server is a web application server for providing services such as online information browsing to the web browser, and the back-end server is located behind the firewall and is in the same local area network as the gateway; It should be noted that the application data is constructed and encapsulated according to a data format specified by the Websocket protocol, and the application data may be transmitted in the form of a data frame.
  • the gateway establishes a data transmission channel based on a transmission control protocol TCP connection between the gateway and the back-end server according to the address information of the back-end server, and saves the address information of the back-end server. To the storage medium.
  • the address information of the backend server may include: a protocol type, a server IP address, and a server port, where the protocol type is a TCP/ adopted when the gateway establishes a TCP connection with the backend server.
  • the gateway establishes a data transmission channel based on a transmission control protocol TCP connection between the gateway and the back-end server according to the IP and port of the back-end server specified by the address information,
  • the upper layer application layer transport protocol is the protocol class Type given TCP/IP protocol.
  • the TCP connection may be kept from being closed for a long time, so that other subsequent web browsers are given to the back end.
  • the storage medium can be queried to obtain a TCP connection-based data transmission channel established between the gateway and the back-end server, and real-time duplexing between other web browsers and the back-end server is implemented. Communication.
  • the gateway sends the application data to the backend server by using the established TCP connection-based data transmission channel.
  • the backend server may also return a delivery confirmation message to the web browser through the gateway.
  • the gateway obtains the back-end server address information in the data packet sent by the web browser, and after establishing a TCP connection with the back-end server, the gateway can keep the TCP from being closed for a long time, thereby implementing the web browser and the back end. Full duplex efficient communication between servers.
  • the fourth embodiment of the present invention provides a gateway, including: a protocol engine module 1 and a storage medium 2, where the protocol engine module 1 includes:
  • the request receiving unit 101 is configured to receive a handshake message of the web browser 6, where the handshake message carries a protocol upgrade request and address information of the web browser 6;
  • the protocol conversion unit 102 is configured to change, according to the protocol upgrade request, an application layer protocol between the web browser 6 and the gateway from a hypertext transfer protocol HTTP to a web socket protocol Websocket, so that the Establishing a Websocket data transmission channel between the Web browser 6 and the gateway;
  • the storage unit 103 is configured to save the address information of the web browser 6 into the storage medium 2.
  • the gateway in this embodiment separately establishes a Websocket data transmission channel with each web browser by shaking hands with a web browser having communication requirements, and also acquires and stores address information of each web browser, and the gateway can be based on any one of them.
  • the address information of the Web browser 6 saved by the storage medium 2 may include: a user group identification ID, a user ID, a network protocol IP address, and a port.
  • the storage medium 2 may be a non-volatile memory, and the non-volatile memory does not disappear after the power supply is interrupted.
  • protocol engine module 1 may further include:
  • the monitoring unit 104 is configured to close a Websocket connection between the Web browser 6 and the gateway.
  • Embodiment 5 when the Websocket connection between the gateway and the Web browser 6 is not used for a long time, or an abnormal situation occurs, for example, when a network attack is suffered, the Web browser 6 and the gateway may be closed.
  • the TCP connection between the transport layers is conducive to saving network resources.
  • the gateway communication device provides a gateway device, including: a receiving module 3, a forwarding module 4, and a storage medium 2;
  • the receiving module 3 is configured to receive a data packet sent by the first web browser 601 to the second web browser 602, where the data packet carries application data and address information of the second web browser 602;
  • the storage medium 2 stores address information of a web browser that has a Websocket data channel established with the gateway;
  • the forwarding module 4 is configured to query the storage medium 2, find a Websocket data transmission channel that matches the address information of the second Web browser 602, and use the Websocket data transmission channel found to find the application. The data is forwarded to the second web browser 602.
  • the gateway compares the address information of the second web browser as the communication destination node with the address information of each web browser previously stored in the storage medium.
  • the Websocket data transmission channel where the second web browser is located can be found, and the full-duplex efficient communication between the two web browsers can be realized through the Websocket data transmission channel.
  • the storage medium 2 may be a non-volatile memory, and the non-volatile Lost memory does not disappear after the power supply is interrupted.
  • the gateway communication method according to the third embodiment further provides a gateway, including: a receiving module 3, other TCP protocol transceiver modules 5, and a storage medium;
  • the receiving module is configured to receive a data packet sent by the web browser to the backend server, where the data packet carries application data and address information of the backend server;
  • the other TCP protocol transceiver module is configured to establish, according to address information of the backend server, a data transmission channel based on a TCP connection between the gateway and the backend server, and establish the TCP-based connection
  • the data transmission channel sends the application data to the backend server
  • the other TCP protocol transceiver module is further configured to save the address information of the backend server to the storage medium.
  • the gateway obtains the address information in the data packet sent by the web browser to the back-end server, and after establishing a TCP connection with the back-end server, the gateway can keep the TCP from being closed for a long time, thereby implementing the web browser and the latter. Efficient communication of full duplex between end servers.
  • a seventh embodiment of the present invention provides a web communication system, including: a gateway, a back end server 7;
  • the gateway includes: a protocol engine module 1, a receiving module 3, a forwarding module 4, other TCP protocol transceiver modules 5, and a storage medium 2;
  • the protocol engine module 1 includes:
  • the request receiving unit 101 is configured to receive a handshake message of the first web browser 601, the second web browser 602, and the Nth web browser 603, respectively, where the handshake message carries a protocol upgrade request and the first web browser 601. Address information of the second web browser 602 or the Nth web browser 603, where N is a natural number;
  • the protocol conversion unit 102 is configured to respectively connect the first web browser 601, the second web browser 602, and/or the Nth web browser 603 and the gateway according to the protocol upgrade request.
  • Application layer transport protocol changed from Hypertext Transfer Protocol HTTP to Web Sockets Protocol a Websocket, a Websocket data transmission channel is established between the first Web browser 601, the second Web browser 602, and/or the Nth Web browser 603 and the gateway;
  • the storage unit 103 is configured to save address information of the first web browser 601, the second web browser 602, and/or the Nth web browser 603 into the storage medium 2;
  • the receiving module 3 is configured to receive a data packet sent by the first web browser 601 to a target node, where the data packet carries application data and address information of the target node;
  • the forwarding module 4 is configured to query the storage medium 2 when the target node is the second web browser 602, and find a Websocket data transmission that matches the address information of the second web browser 602. Channel, and forwarding the application data to the second web browser 602 through the found Websocket data transmission channel;
  • the other TCP protocol transceiver module 5 is configured to establish, between the gateway and the backend server 7, according to the address information of the backend server 7, when the target node is the backend server 7. And the application data is sent to the backend server 7 by using the TCP connection-based data transmission channel, and the other TCP protocol transceiver module 5 is further configured to: The address information of the backend server 7 is saved in the storage medium 2.
  • the Websocket connection is established between the gateway and the web browser, and the address information of the web browser is obtained and saved, and the entire web browser and the web browser to the back server can be realized. Duplex efficient communication.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明实施例公开一种网关握手的方法包括:网关接收网页Web浏览器的握手消息,所述握手消息中携带有协议升级请求以及所述Web浏览器的地址信息;所述网关根据所述协议升级请求,将所述Web浏览器与所述网关之间的应用层协议,由超文本传输协议HTTP改为网页套接字协议Websocket,使所述Web浏览器与所述网关之间建立Websocket数据传输通道;所述网关将所述Web浏览器的地址信息保存到存储介质中。本发明还公开了一种网关通信方法、网关及Web通信系统,采用本发明的技术方案,使得Web浏览器之间,或者Web浏览器与局域网内的后端服务器之间,能够通过网关进行直接全双工的高效通信。

Description

一种网关握手、 通信方法、 网关及 Web通信系统 技术领域
本发明涉及通信领域, 尤其涉及一种网关握手、 通信方法、 网关及 Web 通信系统。 背景技术 随着互联网技术的发展, 很多实时的, 事件驱动的万维网 (World wide Web, Web )应用, 比如 Web实时协作、 Web多人游戏、 Web实时数据推送等, 都要求 Web的通信节点之间直接进行实时全双工(Full Duplex )通信, 即同步 进行数据发送和数据接收。
由于 Web的通信节点往往都位于防火墙之后,相互之间并不可见,它们之 间的通信需要通过中继服务器实现, 而中继服务器作为通信中介或者网关, 在 支持 Web浏览器之间或者是 Web浏览器与局域网内的后端服务器之间的实时 交互时, 一般采用基于 HTTP协议的技术进行通信, 如: 轮询技术( Polling ) 或服务器推技术( Comet )等,其中, Polling技术只能支持半双工通信,而 Comet 采用分别用于上行数据流和下行数据流的两个连接来模拟全双工通信, 需要耗 费双倍的 Web应用服务器资源, 效率低下, 简而言之,基于 HTTP协议的技术 并非为了实现实时全双工通信而设计, 因此, 传统的中继服务器无法支持 Web 浏览器之间,或者 Web浏览器与后端服务器之间,进行直接全双工的高效通信, 以实现实时交互数据。 发明内容 本发明的主要目的在于提供一种网关握手、 通信方法、 网关及 Web系统, 以支持 Web浏览器之间, 或者 Web浏览器与后端服务器之间, 通过网关进行 直接全双工的高效通信, 以实现实时数据交互。
为了实现上述目的, 本发明采用的技术方案如下:
一种网关握手的方法, 包括: 网关接收网页 Web浏览器的握手消息,所述握手消息中携带有协议升级请 求以及所述 Web浏览器的地址信息;
所述网关根据所述协议升级请求,将所述 Web浏览器与所述网关之间的应 用层协议, 由超文本传输协议 HTTP改为网页套接字协议 Websocket, 使所述 Web浏览器与所述网关之间建立 Websocket数据传输通道;
所述网关将所述 Web浏览器的地址信息保存到存储介质中。
一种网关的通信方法, 包括:
网关接收第一 Web浏览器发送给第二 Web浏览器的数据包, 所述数据包 中携带有应用数据及所述第二 Web浏览器的地址信息;
所述网关查询存储介质 ,找到与所述第二 Web浏览器的地址信息相匹配的 网页套接字协议 Websocket数据传输通道;
所述网关通过找到的所述 Websocket数据传输通道, 将所述应用数据转发 给所述第二 Web浏览器。
一种网关的通信方法, 包括:
网关接收 Web浏览器发送给后端服务器的数据包,所述数据包中携带有应 用数据及所述后端服务器的地址信息;
所述网关根据所述后端服务器的地址信息, 在所述网关与所述后端服务器 之间建立基于传输控制协议 TCP连接的数据传输通道, 并将所述后端服务器 的地址信息保存到存储介质中;
所述网关通过建立的所述基于 TCP连接的数据传输通道, 将所述应用数 据发送给所述后端服务器。
一种网关, 包括: 协议引擎模块及存储介质, 所述协议引擎模块包括: 请求接收单元,用于接收 Web浏览器的握手消息,所述握手消息中携带有 协议升级请求以及所述 Web浏览器的地址信息;
协议转换单元,用于根据所述协议升级请求,将所述 Web浏览器与所述网 关之间的应用层协议, 由超文本传输协议 HTTP改为网页套接字协议
Websocket,使所述 Web浏览器与所述网关之间建立 Websocket数据传输通道; 存储单元, 用于将所述 Web浏览器的地址信息保存到所述存储介质中。 一种网关, 包括: 接收模块、 转发模块及存储介质; 所述接收模块用于接收第一 Web浏览器发送给第二 Web浏览器的数据包, 所述数据包中携带有应用数据及所述第二 Web浏览器的地址信息;
所述存储介质保存有与所述网关建立有网页套接字协议 Websocket数据通 道的 Web浏览器的地址信息;
所述转发模块用于查询所述存储介质,找到与所述第二 Web浏览器的地址 信息相匹配的 Websocket数据传输通道, 并通过找到的所述 Websocket数据传 输通道, 将所述应用数据转发给所述第二 Web浏览器。
一种网关, 包括: 接收模块、 其他 TCP协议收发模块及存储介质; 所述接收模块用于接收 Web浏览器发送给后端服务器的数据包,所述数据 包中携带有应用数据及所述后端服务器的地址信息;
所述其他 TCP协议收发模块, 用于根据所述后端服务器的地址信息, 在 所述网关与所述后端服务器之间建立基于 TCP连接的数据传输通道, 并通过 建立的所述基于 TCP 连接的数据传输通道, 将所述应用数据发送给所述后端 服务器, 所述其他 TCP协议收发模块还用于将所述后端服务器的地址信息保 存到所述存储介质中。
一种 Web通信系统, 包括: 网关, 后端服务器;
所述网关包括: 协议引擎模块、 接收模块、 转发模块及存储介质; 所述协议引擎模块包括:
请求接收单元,用于分别接收第一 Web浏览器、第二 Web浏览器、第 NWeb 浏览器的握手消息, 所述握手消息中携带有协议升级请求以及所述第一 Web 浏览器、 所述第二 Web浏览器或所述第 NWeb浏览器的地址信息, 其中, N 为自然数;
协议转换单元 ,用于根据所述协议升级请求 ,分别将所述第一 Web浏览器、 所述第二 Web浏览器和 /或所述第 NWeb浏览器与所述网关之间的应用层传输 协议由超文本传输协议 HTTP改为网页套接字协议 Websocket,使所述第一 Web 浏览器、 所述第二 Web浏览器和 /或所述第 NWeb浏览器与所述网关之间建立 Websocket数据传输通道;
存储单元, 用于将所述第一 Web浏览器、 所述第二 Web浏览器和 /或所述 第 NWeb浏览器的地址信息保存到所述存储介质中; 所述接收模块, 用于接收所述第一 Web浏览器发送给目标节点的数据包, 所述数据包中携带有应用数据及所述目标节点的地址信息;
所述转发模块,用于当所述目标节点为所述第二 Web浏览器时,查询所述 存储介质,找到与所述第二 Web浏览器的地址信息相匹配的 Websocket数据传 输通道, 并通过找到的所述 Websocket数据传输通道, 将所述应用数据转发给 所述第二 Web浏览器。
采用本发明的技术方案, 可以在网关与 Web 浏览器之间建立一个 Websocket连接, 即一个全双工的 Websocket数据传输通道, 以支持 Web浏览 器之间,或者 Web浏览器与局域网内的后端服务器之间,通过网关进行直接全 双工的高效通信, 以实时交互数据。 附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实施 例或现有技术描述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述 中的附图仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付 出创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。
图 1为本发明实施例一提供的一种网关握手的方法流程图;
图 2为本发明实施例一提供的网关握手方法中网关获取并保存握手消息携 带的 Web浏览器的地址信息的示意图;
图 3为本发明实施例二提供的一种 Web浏览器之间通信的方法流程图; 图 4为本发明实施例三提供的一种 Web浏览器与后端服务器通信的方法流 程图;
图 5为本发明实施例四提供的一种网关示意图;
图 6为本发明实施例五提供的一种网关示意图;
图 7为本发明实施例六提供的一种网关示意图;
图 8为本发明实施例七提供的一种一种 Web通信系统示意图。 具体实施方式 下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清 楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而不是 全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有作出创造 性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。
为使本领域一般技术人员更好的了解本发明实施例提供的技术方案, 对万 维网 (World Wide Web , Web )通信中采用的超文本传输协议 (Hyper Text Transfer Protocol, HTTP)以及网页套接字(Websocket )的通信机制分别做简要 的介绍:
HTTP协议是互联网上应用最为广泛的一种网络协议, HTTP协议定义 了 Web客户端与 Web应用服务器请求和应答的标准, 所有的 Web文件都必须 遵守这个标准。
基于 HTTP协议的 Web客户端 /应用服务器请求响应机制的信息交换过程 包括四个步骤:
( 1 )建立连接: Web客户端与 Web应用服务器的指定端口 (对于 HTTP 默认端口为 80 , 对于具有安全性的 HTTPS , 默认端口为 443 ) 建立 TCP ( Transmission Control Protocol, 传输控制协议 )连接。 HTTP是比 TCP更高 层次的应用层协议, 根据规则, 只有低层协议建立之后才能进行更高层协议的 连接, 因此, 首先要建立 TCP连接;
( 2 )发送请求: 建立一个 TCP连接后, Web客户端把请求消息送到 Web 应用服务器的相应端口上, 请求消息包含: 请求的方法、 U L、 协议版本、 请 求头部以及请求数据等, 完成请求动作提交;
( 3 )发送响应: Web应用服务器在处理完 Web客户端请求之后, 要向 Web客户端发送响应消息响应消息的内容包括消息协议的版本、成功或者错误 编码加上包含 Web应用服务器信息、 实体元信息以及可能的实体内容;
( 4 ) 关闭连接: Web客户端和 Web应用服务器双方都可以通过关闭套接 字来结束 TCP/IP对话。
基于 HTTP协议的通信技术存在以下缺点:
1 )无法实现点对点的全双工通信。 由于传统的 HTTP轮询是半双工, 而基 于 HTTP协议的 Comet技术需要在两条连接上实现双向通信,都无法支持通过一 个连接实现点对点的全双工的实时通信; 2 )资源浪费严重。由于采用的 HTTP协议所承载的信息往往只有几个字节, 而 HTTP头过大(近 1K ) , 即无效信息载荷多, 因此, 频繁的轮询造成系统带 宽消耗大、 延迟高, 效率低下。 Websocket是 HTML5中定义的一种新的协议,支持 Web客户端与 Web应 用服务器之间通过一个 Websocket连接进行全双工的高效通信。 Websocket有 着兼容 HTTP的握手机制,可以共享默认的 HTTP与 HTTPS端口( 80和 443 ), Websocket的通信机制如下:
( 1 )握手:
Web客户端可以通过给 Web应用服务器发送握手消息, 将 Web客户端与
Web应用月良务器之间的 HTTP协议提升为 Websocket协议以建立 Websocket连 接,具体的 , Web客户端( example.com )给 Web应用月良务器( server. example . com ) 发送一个 HTTP Upgrade请求, 例如:
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Origin: htt : //example .com
Sec-WebSocket-Protocol: chat, superchat
(\r\n)
其中, Host为 Web应用服务器主机, Upgrade为协议升级类型, Connection 为连接类型, Key 为安全认证密钥, Origin为请求来源, Protocol为可选的子 协议名称;
Web应用服务器接受 HTTP Upgrade请求,并返回响应消息给 Web客户端, 如:
HTTP/ 1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade Sec-WebSocket-Origin: htt:〃 example. com
Sec-WebSocket-Location: ws:〃 example. com/demo
Sec-WebSocket-Protocol: sample
8jKS'y:G*Co,Wxa- 其中, 101为 HTTP响应状态码( 101 :客户要求服务器根据请求转换 HTTP 协议版本), Origin必须等于 HTTP Upgrade请求的来源, Location必须等于 HTTP Upgrade请求的地址, Protocol必须包含 HTTP Upgrade请求的子协议名, "8jKS,y:G*Co,Wxa-,,为把由 HTTP Upgrade请求中的 Key构造的 16字节的数 据, 进行 MD5加密得到一个 16字节的值;
( 2 )数据传输:
Websocket连接建立之后, Websocket数据帧就可以以全双工的模式在 Web 客户端和 Web应用服务器之间来回传输。 实施例一
图 1为本发明实施例一提供的一种网关握手的方法流程图。
如图 1所示, 本发明实施例一的网关握手的方法包括:
5101 , 网关接收网页 Web浏览器的握手消息, 所述握手消息中携带有协 议升级请求以及所述 Web浏览器的地址信息。
需要说明的是, 所述协议升级请求一般为一个 HTTP GET请求, 具体的例 子可以为如下代码所示:
GET /real-time HTTP/1. l\r\n
Upgrade: WebSocket\r\n
Connection: Upgrade\r\n
...\r\n
可以在所述 HTTP GET请求中, 通过新增信元的方式携带所述 Web浏览 器的地址信息。
5102, 所述网关根据所述协议升级请求, 将所述 Web 浏览器与所述网关 之间的应用层协议,由超文本传输协议 HTTP改为网页套接字协议 Websocket, 使所述 Web浏览器与所述网关之间建立 Websocket数据传输通道。 需要说明的是, 所述网关将 HTTP协议升级为 Websocket协议之后, 还可 以返回响应消息给所述 Web浏览器。
所述响应消息具体可以为所述 WebSocket网关对所述协议升级请求作出的 HTTP响应的消息, 所述响应消息的一个例子可以为如下代码所示:
HTTP/ 1.1 101 WebSocket Protocol Handshake\r\n
Upgrade: WebSocket\r\n
Connection: Upgrade\r\n
...\r\n
5103 , 所述网关将所述 Web浏览器的地址信息保存到存储介质中。
具体而言, 所述存储介质可以为非易失性的持久存储介质, 进一步地, 所 述网关可以在所述存储介质中建立一个初始化的转发表, 握手时读取的所述 Web浏览器的地址信息, 并更新到所述转发表中。
需要说明的是,本实施例中 S102和 S103的顺序不应用于限制本发明, S102 和 S103可以为并行处理, 或者 S103还可以先于 S102处理。
本实施例的方法中, 网关可以通过与有通信需求的 Web浏览器逐一握手, 分别与各个 Web浏览器建立 Websocket连接, 同时获取并保存各个 Web浏览 器的地址信息, 网关可以根据其中任一个 Web浏览器的地址信息,找到网关与 该 Web浏览器的 Websocket连接,以便于进一步发送数据给浏览器或者后端服 务器。
具体地, 在 S103中, 参见图 2, 所述 Web浏览器的地址信息可以包括: 用户组标识 ID, 用户 ID, 网络协议 IP地址及端口, 其中, 所述用户组 ID为 所述 Web浏览器所在的通信群组标识,具体而言,通信群组可以与腾讯的即时 聊天工具 QQ中的群组概念类似,所述用户 ID是所述 Web浏览器的身份标识, 不同用户 ID的 Web浏览器只有在用户组 ID相同时才可以相互通信。
进一步地, 本实施例中, 还包括:
5104, 所述网关关闭所述 Web 浏览器与所述网关之间的所述 Websocket 数据传输通道。
具体地,当所述网关与所述 Web浏览器之间的 Websocket连接长时间不使 用, 或者出现异常情况, 例如遭受网络攻击时, 可以关闭所述 Web浏览器与所 述网关之间的所述 Websocket数据传输通道, 具体而言, 关闭所述 Web浏览器 与网关所述之间传输层的 TCP连接, 有利于节省网络资源。 实施例二
基于实施例一所述的网关握手的方法, 如图 3所示, 本发明实施例二提供 了一种网关的通信方法, 包括如下步骤:
5201 , 网关接收第一 Web浏览器发送给第二 Web浏览器的数据包, 所述 数据包中携带有应用数据及所述第二 Web浏览器的地址信息。
其中,所述第一 Web浏览器作为通信发起节点,所述第二浏览器作为通信 目标节点。
需要说明的是, 所述数据包中的所述应用数据, 是按照 Websocket协议规 定的数据格式构造并封装的, 所述应用数据可以以数据帧的形式进行传输。
需要进一步说明的是,所述数据包中一般是将第二 Web浏览器的地址信息 封装为一个头文件再进行传输, 所述网关通过对该头文件进行解析, 得到所述 第二 Web浏览器的地址信息; 本领域技术人员应当知道, OSI ( Open System Interconnection,开放系统互连)把网络从逻辑上分为了七层,分别为: 物理层、 数据链路层、 网络层、 传输层、 会话层、 表示层、 应用层, OSI七层模型是一 种框架性的设计方法, 建立七层模型的主要目的是为解决异种网络互连时所遇 到的兼容性问题, 以帮助不同类型的通信节点实现数据传输, 当通信节点的应 用层的数据发送给目标节点时, 会将数据逐层封装成数据包后, 通过传输介质 发送给目标节点, 因此, 网关通过对数据包进行解析, 具体而言, 可以对数据 包的头文件进行七层分析, 从而获取目标节点的地址信息, 根据目标节点的地 址信息, 还可以判断目标节点为 Web浏览器, 还是局域网内的后端服务器。
5202, 所述网关查询存储介质, 找到与所述第二 Web 浏览器的地址信息 相匹配的 Websocket数据传输通道。
具体地,所述网关将所述第二 Web浏览器的地址信息,与所述网关的存储 介质中保存的各个 Web浏览器的地址信息进行比对, 例如, 通过查询转发表, 找到所述第二 Web浏览器所在的 Websocket数据传输通道。
5203 , 所述网关通过找到的所述 Websocket数据传输通道, 将所述应用数 据转发给所述第二 Web浏览器。
需要说明的是,所述第二 Web浏览器接收到所述应用数据后,还可以通过 网关给所述第一 Web浏览器返回送达确认消息。
本实施例的方法中, 当两个 Web浏览器之间通信时, 网关通过将作为通信 目标节点的第二 Web浏览器的地址信息与事先保存在存储介质中的各个 Web 浏览器的地址信息进行比对,可以找到第二 Web浏览器所在的 Websocket数据 传输通道, 并通过该 Websocket数据传输通道,从而实现两个 Web浏览器之间 基于 Websocket协议的实时的全双工高效通信。
具体地, 所述第二 Web浏览器的地址信息可以包括: 用户组 ID、用户 ID、 IP地址及端口。 实施例三
基于实施例一的网关握手方法, 如图 4所示, 本发明实施例三还提供了一 种网关的通信方法, 包括如下步骤:
S301 , 网关接收 Web 浏览器发送给后端服务器的数据包, 所述数据包中 携带有应用数据及所述后端服务器的地址信息。
需要说明的是,所述后端服务器是用于向所述 Web浏览器提供网上信息浏 览等服务的 Web应用服务器,所述后端服务器位于防火墙之后且与所述网关处 于同一个局域网内; 进一步需要说明的是, 所述应用数据是按照 Websocket协 议规定的数据格式构造并封装的, 所述应用数据可以以数据帧的形式进行传 输。
S302, 所述网关根据所述后端服务器的地址信息, 在所述网关与所述后端 服务器之间建立基于传输控制协议 TCP 连接的数据传输通道, 并将所述后端 服务器的地址信息保存到存储介质中。
具体地, 所述后端服务器的地址信息可以包括: 协议类型, 服务器 IP地 址及服务器端口, 其中, 所述协议类型为所述网关与所述后端服务器建立 TCP 连接时, 所采用的 TCP/IP协议的类型, 所述网关按照所述地址信息指定的所 述后端服务器的 IP及端口, 在所述网关与所述后端服务器之间建立基于传输 控制协议 TCP连接的数据传输通道, 其上层的应用层传输协议为所述协议类 型给出的 TCP/IP协议。
进一步地, 所述网关与所述后端服务器之间建立基于传输控制协议 TCP 连接的数据传输通道之后, 可以保持所述 TCP连接长时间不关闭, 使得后续 的其他 Web浏览器给所述后端服务器发送数据包时,可以查询存储介质得到所 述网关与所述后端服务器之间建立的基于 TCP连接的数据传输通道, 实现其 它 Web浏览器与所述后端服务器之间的实时的双工通信。
S303 , 所述网关通过建立的所述基于 TCP连接的数据传输通道, 将所述 应用数据发送给所述后端服务器。
需要说明的是, 所述后端服务器接收到所述应用数据后, 还可以通过所述 网关给所述 Web浏览器返回送达确认消息。
本实施例中,网关通过获取 Web浏览器发送的数据包中的后端服务器地址 信息, 与后端服务器建立 TCP连接后, 网关可以保持该 TCP长时间不关闭, 从而实现 Web浏览器与后端服务器之间的全双工高效通信。 实施例四
如图 5所示, 基于实施例一的网关握手方法, 本发明实施例四提供了一种 网关, 包括: 协议引擎模块 1及存储介质 2, 所述协议引擎模块 1包括:
请求接收单元 101 , 用于接收 Web浏览器 6的握手消息, 所述握手消息中 携带有协议升级请求以及所述 Web浏览器 6的地址信息;
协议转换单元 102, 用于根据所述协议升级请求, 将所述 Web浏览器 6与 所述网关之间的应用层协议, 由超文本传输协议 HTTP 改为网页套接字协议 Websocket, 使所述 Web浏览器 6与所述网关之间建立 Websocket数据传输通 道;
存储单元 103 ,用于将所述 Web浏览器 6的地址信息保存到所述存储介质 2中。
本实施例中的网关,通过与有通信需求的 Web浏览器逐一握手,分别与各 个 Web浏览器建立 Websocket数据传输通道, 同时还获取并保存各个 Web浏 览器的地址信息, 网关可以根据其中任一个 Web浏览器的地址信息,查询存储 介质,找到网关与该 Web浏览器的 Websocket数据传输通道,有利于实现 Web 浏览器之间或者 Web浏览器与后端服务器的全双工高效通信。
本实施例中,具体地,所述存储介质 2保存的所述 Web浏览器 6的地址信 息可以包括: 用户组标识 ID、 用户 ID、 网络协议 IP地址及端口。
本实施例中, 具体地, 所述存储介质 2可以为非易失性存储器, 所述非易 失性存储器在电源供应中断后, 保存的数据不会消失。
本实施例中, 进一步地, 所述协议引擎模块 1还可以包括:
监控单元 104, 用于关闭所述 Web浏览器 6与所述网关之间的 Websocket 连接。
需要说明的是,当所述网关与所述 Web浏览器 6之间的 Websocket连接长 时间不使用, 或者出现异常情况, 例如遭受网络攻击时, 可以关闭所述 Web 浏览器 6与网关所述之间传输层的 TCP连接, 且有利于节省网络资源。 实施例五
如图 6所示,基于实施例二的网关通信方法,本发明提供了一种网关装置, 包括: 接收模块 3、 转发模块 4及存储介质 2;
所述接收模块 3用于接收第一 Web浏览器 601发送给第二 Web浏览器 602 的数据包,所述数据包中携带有应用数据及所述第二 Web浏览器 602的地址信 息;
所述存储介质 2保存有与所述网关建立有 Websocket数据通道的 Web浏览 器的地址信息;
所述转发模块 4用于查询所述存储介质 2,找到与所述第二 Web浏览器 602 的地址信息相匹配的 Websocket数据传输通道, 并通过找到的所述 Websocket 数据传输通道, 将所述应用数据转发给所述第二 Web浏览器 602。
本实施例中, 当两个 Web浏览器之间通信时, 网关通过将作为通信目标节 点的第二 Web浏览器的地址信息与事先保存在存储介质中的各个 Web浏览器 的地址信息进行比对,可以找到第二 Web浏览器所在的 Websocket数据传输通 道, 通过该 Websocket数据传输通道, 可以实现两个 Web浏览器之间的全双工 的高效通信。
本实施例中, 具体地, 所述存储介质 2可以为非易失性存储器, 所述非易 失性存储器在电源供应中断后, 保存的数据不会消失。 实施例六
如图 7所示, 基于实施例三的网关通信方法, 本发明还提供了一种网关, 包括: 接收模块 3、 其他 TCP协议收发模块 5及存储介质;
所述接收模块用于接收 Web浏览器发送给后端服务器的数据包,所述数据 包中携带有应用数据及所述后端服务器的地址信息;
所述其他 TCP协议收发模块, 用于根据所述后端服务器的地址信息, 在 所述网关与所述后端服务器之间建立基于 TCP连接的数据传输通道, 并通过 建立的所述基于 TCP 连接的数据传输通道, 将所述应用数据发送给所述后端 服务器, 所述其他 TCP协议收发模块还用于将所述后端服务器的地址信息保 存到所述存储介质中。
本实施例中,网关通过获取 Web浏览器发送给后端服务器的数据包中的地 址信息, 与后端服务器建立 TCP连接后, 网关可以保持该 TCP长时间不关闭, 从而实现 Web浏览器与后端服务器之间的全双工的高效通信。 实施例七
如图 8所示, 本发明实施例七提供了一种 Web通信系统, 包括: 网关, 后 端服务器 7;
所述网关包括: 协议引擎模块 1、 接收模块 3、 转发模块 4、 其他 TCP协 议收发模块 5及存储介质 2;
所述协议引擎模块 1包括:
请求接收单元 101 , 用于分别接收第一 Web浏览器 601 , 第二 Web浏览器 602及第 NWeb浏览器 603的握手消息, 所述握手消息中携带有协议升级请求 以及所述第一 Web浏览器 601、 所述第二 Web浏览器 602或所述第 NWeb浏 览器 603的地址信息, 其中, N为自然数;
协议转换单元 102, 用于根据所述协议升级请求, 分别将所述第一 Web浏 览器 601、 所述第二 Web浏览器 602和 /或所述第 NWeb浏览器 603与所述网 关之间的应用层传输协议由超文本传输协议 HTTP 改为网页套接字协议 Websocket, 使所述第一 Web浏览器 601、 所述第二 Web浏览器 602和 /或所述 第 NWeb浏览器 603与所述网关之间建立 Websocket数据传输通道;
存储单元 103 , 用于将所述第一 Web浏览器 601、 所述第二 Web浏览器 602和 /或所述第 NWeb浏览器 603的地址信息保存到所述存储介质 2中;
所述接收模块 3 ,用于接收所述第一 Web浏览器 601发送给目标节点的数 据包, 所述数据包中携带有应用数据及所述目标节点的地址信息;
所述转发模块 4, 用于当所述目标节点为所述第二 Web浏览器 602时, 查 询所述存储介质 2, 找到与所述第二 Web 浏览器 602 的地址信息相匹配的 Websocket数据传输通道, 并通过找到的所述 Websocket数据传输通道, 将所 述应用数据转发给所述第二 Web浏览器 602;
所述其他 TCP协议收发模块 5, 用于当所述目标节点为所述后端服务器 7 时, 根据所述后端服务器 7的地址信息, 在所述网关与所述后端服务器 7之间 建立基于 TCP连接的数据传输通道, 并通过建立的所述基于 TCP连接的数据 传输通道, 将所述应用数据发送给所述后端服务器 7; 所述其他 TCP协议收发 模块 5还用于将所述后端服务器 7的地址信息保存到所述存储介质 2中。
本实施例的 Web通信系统中, 通过网关与 Web浏览器建立 Websocket连 接, 并获取和保存 Web浏览器的地址信息, 可以实现 Web浏览器之间, 以及 Web浏览器到后端服务器之间的全双工高效通信。
需要说明的是, 上述实施例一至实施例七中的相应技术特征可以相互参 考。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程, 是可以通过计算机程序来指令相关的硬件来完成, 所述的程序可存储于一计算 机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。 其中, 所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory, ROM )或随机存储记忆体(Random Access Memory, RAM )等。
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其限 制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术人员 应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其 中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技术方案的 本质脱离本发明各实施例技术方案的范围

Claims

权 利 要 求
1、 一种网关握手的方法, 其特征在于, 包括:
网关接收网页 Web浏览器的握手消息,所述握手消息中携带有协议升级请 求以及所述 Web浏览器的地址信息;
所述网关根据所述协议升级请求,将所述 Web浏览器与所述网关之间的应 用层协议, 由超文本传输协议 HTTP改为网页套接字协议 Websocket, 使所述 Web浏览器与所述网关之间建立 Websocket数据传输通道;
所述网关将所述 Web浏览器的地址信息保存到存储介质中。
2、 权利要求 1所述的方法, 其特征在于, 所述 Web浏览器的地址信息包 括: 用户组标识 ID、 用户 ID、 网络协议 IP地址及端口。
3、 权利要求 1或 2所述的方法, 其特征在于, 所述方法还包括: 所述网关关闭所述 Websocket数据传输通道。
4、 一种网关的通信方法, 其特征在于, 包括:
网关接收第一 Web浏览器发送给第二 Web浏览器的数据包, 所述数据包 中携带有应用数据及所述第二 Web浏览器的地址信息;
所述网关查询存储介质,找到与所述第二 Web浏览器的地址信息相匹配的 网页套接字协议 Websocket数据传输通道;
所述网关通过找到的所述 Websocket数据传输通道, 将所述应用数据转发 给所述第二 Web浏览器。
5、 权利要求 4所述的方法, 其特征在于, 所述第二 Web浏览器的地址信 息包括: 用户组 ID、 用户 ID、 IP地址及端口。
6、 一种网关的通信方法, 其特征在于, 包括:
网关接收 Web浏览器发送给后端服务器的数据包,所述数据包中携带有应 用数据及所述后端服务器的地址信息;
所述网关根据所述后端服务器的地址信息, 在所述网关与所述后端服务器 之间建立基于传输控制协议 TCP连接的数据传输通道, 并将所述后端服务器 的地址信息保存到存储介质中;
所述网关通过建立的所述基于 TCP连接的数据传输通道, 将所述应用数 据发送给所述后端服务器。
7、 如权利要求 6所述的通信方法, 其特征在于, 所述后端服务器的地址 信息包括: 协议类型、 服务器 IP地址及服务器端口。
8、 一种网关, 其特征在于, 包括: 协议引擎模块及存储介质, 所述协议 引擎模块包括:
请求接收单元,用于接收 Web浏览器的握手消息,所述握手消息中携带有 协议升级请求以及所述 Web浏览器的地址信息;
协议转换单元,用于根据所述协议升级请求,将所述 Web浏览器与所述网 关之间的应用层协议, 由超文本传输协议 HTTP改为网页套接字协议
Websocket,使所述 Web浏览器与所述网关之间建立 Websocket数据传输通道; 存储单元, 用于将所述 Web浏览器的地址信息保存到所述存储介质中。
9、 如权利要求 8所述的网关, 其特征在于, 保存到所述存储介质中的所 述 Web浏览器的地址信息包括: 用户组 ID、 用户 ID、 IP地址及端口。
10、 如权利要求 8或 9所述的网关, 其特征在于, 所述存储介质为非易失 性存储器。
11、 如权利要求 8至 10任一所述的网关, 其特征在于, 所述协议引擎模 块还包括:
监控单元, 用于关闭所述 Websocket数据传输通道。
12、 一种网关, 其特征在于, 包括: 接收模块、 转发模块及存储介质; 所述接收模块用于接收第一 Web浏览器发送给第二 Web浏览器的数据包, 所述数据包中携带有应用数据及所述第二 Web浏览器的地址信息;
所述存储介质保存有与所述网关建立有网页套接字协议 Websocket数据通 道的 Web浏览器的地址信息;
所述转发模块用于查询所述存储介质,找到与所述第二 Web浏览器的地址 信息相匹配的 Websocket数据传输通道, 并通过找到的所述 Websocket数据传 输通道, 将所述应用数据转发给所述第二 Web浏览器。
13、 一种网关, 其特征在于, 包括: 接收模块、 其他 TCP协议收发模块 及存储介质;
所述接收模块用于接收 Web浏览器发送给后端服务器的数据包,所述数据 包中携带有应用数据及所述后端服务器的地址信息; 所述其他 TCP协议收发模块, 用于根据所述后端服务器的地址信息, 在 所述网关与所述后端服务器之间建立基于 TCP连接的数据传输通道, 并通过 建立的所述基于 TCP连接的数据传输通道, 将所述应用数据发送给所述后端 服务器, 所述其他 TCP协议收发模块还用于将所述后端服务器的地址信息保 存到所述存储介质中。
14、 一种 Web通信系统, 其特征在于, 包括: 网关, 后端服务器; 所述网关包括: 协议引擎模块、 接收模块、 转发模块及存储介质; 所述协议引擎模块包括:
请求接收单元,用于分别接收第一 Web浏览器、第二 Web浏览器、第 NWeb 浏览器的握手消息, 所述握手消息中携带有协议升级请求以及所述第一 Web 浏览器、 所述第二 Web浏览器或所述第 NWeb浏览器的地址信息, 其中, N 为自然数;
协议转换单元,用于根据所述协议升级请求,分别将所述第一 Web浏览器、 所述第二 Web浏览器和 /或所述第 NWeb浏览器与所述网关之间的应用层传输 协议由超文本传输协议 HTTP改为网页套接字协议 Websocket,使所述第一 Web 浏览器、 所述第二 Web浏览器和 /或所述第 NWeb浏览器与所述网关之间建立 Websocket数据传输通道;
存储单元, 用于将所述第一 Web浏览器、 所述第二 Web浏览器和 /或所述 第 NWeb浏览器的地址信息保存到所述存储介质中;
所述接收模块, 用于接收所述第一 Web浏览器发送给目标节点的数据包, 所述数据包中携带有应用数据及所述目标节点的地址信息;
所述转发模块,用于当所述目标节点为所述第二 Web浏览器时,查询所述 存储介质,找到与所述第二 Web浏览器的地址信息相匹配的 Websocket数据传 输通道, 并通过找到的所述 Websocket数据传输通道, 将所述应用数据转发给 所述第二 Web浏览器。
15、 如权利要求 14所述的通信系统, 其特征在于, 所述网关还包括: 其 他 TCP协议收发模块;
所述其他 TCP协议收发模块, 用于当所述目标节点为所述后端服务器时, 根据所述后端服务器的地址信息, 在所述网关与所述后端服务器之间建立基于 TCP连接的数据传输通道, 并通过建立的所述基于 TCP连接的数据传输通道, 将所述应用数据发送给所述后端服务器。
16、 如权利要求 15所述的通信系统, 其特征在于, 所述其他 TCP协议收 发模块还用于将所述后端服务器的地址信息保存到所述存储介质中。
PCT/CN2012/075780 2012-01-06 2012-05-19 一种网关握手、通信方法、网关及Web通信系统 WO2013102335A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210004360.X 2012-01-06
CN201210004360.XA CN102546800B (zh) 2012-01-06 2012-01-06 一种网关握手、通信方法、网关及Web通信系统

Publications (1)

Publication Number Publication Date
WO2013102335A1 true WO2013102335A1 (zh) 2013-07-11

Family

ID=46352746

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/075780 WO2013102335A1 (zh) 2012-01-06 2012-05-19 一种网关握手、通信方法、网关及Web通信系统

Country Status (2)

Country Link
CN (1) CN102546800B (zh)
WO (1) WO2013102335A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103702238A (zh) * 2013-12-23 2014-04-02 华为终端有限公司 一种多屏视频共享方法及终端、服务器
CN112486446A (zh) * 2020-12-01 2021-03-12 佳都新太科技股份有限公司 一种基于服务器的内容编辑方法及装置
CN112788144A (zh) * 2021-01-19 2021-05-11 深圳市位元领航科技有限公司 一种通信方式的实现方法、服务器以及客户端
CN113420408A (zh) * 2021-05-14 2021-09-21 上海霍普建筑设计事务所股份有限公司 Cad网络化导入系统和导入方法
CN113487849A (zh) * 2021-07-02 2021-10-08 北京睿芯高通量科技有限公司 一种新型智能安防系统及其目标人员预警方法
CN113766010A (zh) * 2021-08-09 2021-12-07 深圳前海爱客风信息技术有限公司 数据流处理方法和装置

Families Citing this family (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102932436A (zh) * 2012-10-19 2013-02-13 广东中科遥感技术有限公司 遥感远程会商与协同标绘系统、浏览器、服务器及方法
CN102938788B (zh) * 2012-11-15 2016-03-30 易程科技股份有限公司 事件的处理方法和装置
US9253262B2 (en) * 2013-01-24 2016-02-02 Rovi Guides, Inc. Systems and methods for connecting media devices through web sockets
CN103401942B (zh) * 2013-08-12 2016-05-04 网宿科技股份有限公司 内容分发网络节点实现web应用加速的方法和系统
CN103634382B (zh) * 2013-11-20 2019-10-18 科大讯飞股份有限公司 一种在网页上实现实时交互的系统及方法
US9231946B2 (en) * 2014-02-07 2016-01-05 Oracle International Corporation Mobile cloud service architecture
CN104484823B (zh) * 2014-11-26 2018-05-04 中金金融认证中心有限公司 电子银行pki服务方法及其系统
CN106534052B (zh) * 2015-09-15 2020-11-06 中移(杭州)信息技术有限公司 一种通信处理方法及电子设备
CN105245446B (zh) * 2015-09-22 2019-02-19 上海华为技术有限公司 一种报文发送方法及网关
CN105450479A (zh) * 2016-01-04 2016-03-30 山东超越数控电子有限公司 一种监控模块的方法及装置
CN106330955B (zh) * 2016-09-23 2019-10-29 奕甲智能技术(上海)有限公司 一种即时通讯扩展方法及系统
CN106453433B (zh) * 2016-12-20 2019-09-13 北京数码视讯科技股份有限公司 多信令协议互通方法及多信令转换设备
CN106790717A (zh) * 2017-03-15 2017-05-31 福建中金在线信息科技有限公司 一种网页通讯方法及装置
CN108123940B (zh) * 2017-12-18 2020-07-24 中国科学院深圳先进技术研究院 基于socket的异步通信方法、存储介质及处理器
CN109005190B (zh) * 2018-08-31 2020-10-30 浙江百应科技有限公司 一种在网页上实现全双工语音对话和页面控制的方法
CN110650202B (zh) * 2019-09-26 2021-02-19 支付宝(杭州)信息技术有限公司 通信交互方法、装置及电子设备
CN110830369A (zh) * 2019-11-13 2020-02-21 山西省工业设备安装集团有限公司 一种基于nodejs的智慧工地数据服务网关
CN110888329A (zh) * 2019-11-14 2020-03-17 深圳市力合微电子股份有限公司 设备厂家开放式接入的智能家居平台及其数据处理方法
CN111510476B (zh) * 2020-04-03 2023-06-20 金蝶软件(中国)有限公司 通信方法、装置、计算机设备和计算机可读存储介质
CN111831368A (zh) * 2020-05-25 2020-10-27 武汉烽火众智数字技术有限责任公司 一种浏览器应用与桌面应用交互的方法、系统及存储介质
CN111934840A (zh) * 2020-06-29 2020-11-13 北京百度网讯科技有限公司 客户端和服务端的通信方法、网关、电子设备及存储介质
CN111884861B (zh) * 2020-08-03 2022-07-29 南京信息职业技术学院 一种基于Netty的物联网设备实时告警方法
CN112468502B (zh) * 2020-11-27 2022-07-01 杭州梦视网络科技有限公司 一种基于Websocket协议的嵌入式设备远程实验方法
CN114679398B (zh) * 2020-12-24 2024-03-22 中国移动通信有限公司研究院 网页拨测的数据补偿方法及装置
CN114979189B (zh) * 2021-02-19 2024-05-07 上海宝信软件股份有限公司 基于元数据的时空大数据rest微服务数据交互方法和系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101043392A (zh) * 2006-04-28 2007-09-26 华为技术有限公司 一种WiMAX网络中转发IP报文的装置及基站设备
WO2010127327A1 (en) * 2009-05-01 2010-11-04 Kaazing Corporation Enterprise client-server system and methods of providing web application support through distributed emulation of websocket communications
WO2010138883A1 (en) * 2009-05-28 2010-12-02 Kaazing Corporation System and methods for providing stateless security management for web applications using non-http communications protocols
CN101990193A (zh) * 2009-08-07 2011-03-23 中兴通讯股份有限公司 空闲模式下终端位置更新及改变工作协议模式的操作方法
CN102299967A (zh) * 2011-09-08 2011-12-28 中兴通讯股份有限公司 移动座席系统、网关、移动终端及实现移动座席的方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101043392A (zh) * 2006-04-28 2007-09-26 华为技术有限公司 一种WiMAX网络中转发IP报文的装置及基站设备
WO2010127327A1 (en) * 2009-05-01 2010-11-04 Kaazing Corporation Enterprise client-server system and methods of providing web application support through distributed emulation of websocket communications
WO2010138883A1 (en) * 2009-05-28 2010-12-02 Kaazing Corporation System and methods for providing stateless security management for web applications using non-http communications protocols
CN101990193A (zh) * 2009-08-07 2011-03-23 中兴通讯股份有限公司 空闲模式下终端位置更新及改变工作协议模式的操作方法
CN102299967A (zh) * 2011-09-08 2011-12-28 中兴通讯股份有限公司 移动座席系统、网关、移动终端及实现移动座席的方法

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103702238A (zh) * 2013-12-23 2014-04-02 华为终端有限公司 一种多屏视频共享方法及终端、服务器
CN103702238B (zh) * 2013-12-23 2017-11-28 华为终端有限公司 一种多屏视频共享方法及终端、服务器
CN112486446A (zh) * 2020-12-01 2021-03-12 佳都新太科技股份有限公司 一种基于服务器的内容编辑方法及装置
CN112486446B (zh) * 2020-12-01 2023-12-01 佳都科技集团股份有限公司 一种基于服务器的内容编辑方法及装置
CN112788144A (zh) * 2021-01-19 2021-05-11 深圳市位元领航科技有限公司 一种通信方式的实现方法、服务器以及客户端
CN113420408A (zh) * 2021-05-14 2021-09-21 上海霍普建筑设计事务所股份有限公司 Cad网络化导入系统和导入方法
CN113420408B (zh) * 2021-05-14 2024-03-19 上海霍普建筑设计事务所股份有限公司 Cad网络化导入系统和导入方法
CN113487849A (zh) * 2021-07-02 2021-10-08 北京睿芯高通量科技有限公司 一种新型智能安防系统及其目标人员预警方法
CN113766010A (zh) * 2021-08-09 2021-12-07 深圳前海爱客风信息技术有限公司 数据流处理方法和装置

Also Published As

Publication number Publication date
CN102546800A (zh) 2012-07-04
CN102546800B (zh) 2015-03-25

Similar Documents

Publication Publication Date Title
WO2013102335A1 (zh) 一种网关握手、通信方法、网关及Web通信系统
EP1892887B1 (en) Communication method between communication devices and communication apparatus
CN101247353B (zh) 流老化方法及网络设备
EP3780440A1 (en) Transmission control method and apparatus
US9787770B2 (en) Communication system utilizing HTTP
WO2013097401A1 (zh) 浏览器客户端与后端服务器直通的方法、网关和通信系统
WO2013056628A1 (zh) 实现心跳机制的方法、应用服务器、网络数据库及系统
WO2014023003A1 (zh) 控制数据传输的方法、装置和系统
WO2013086897A1 (zh) 生成表项的方法、接收报文的方法及相应装置和系统
CN103108037B (zh) 一种通信方法,Web服务器及Web通信系统
JP2017118545A5 (zh)
WO2011015020A1 (zh) 文件传输方法、系统及客户端
WO2013120325A1 (zh) 浏览器与浏览器直通的方法、装置和通信系统
WO2007019809A1 (fr) Procede et systeme d'etablissement d'un canal direct point par point
US20140337478A1 (en) Peer-to-peer network communications
FI123673B (fi) Menetelmä, järjestelmä ja elementti yleiskäyttöiseen tietoliikenteen tietovirran hallintaan ja tietoliikenteen reititykseen
CN110771117B (zh) 一种采用面向id的网络的会话层通信
WO2013152614A1 (zh) 一种基于应用层数据的网络接入系统和方法
WO2013185696A2 (zh) 一种数据处理的方法与设备
WO2014198229A1 (zh) 报文处理方法、设备和系统
Berry et al. PPP over Ethernet (PPPoE) extensions for credit flow and link metrics
CN113794715B (zh) 一种虚拟点对点网络数据发送方法及其系统
KR101200875B1 (ko) 웹 서비스 기반 관리를 위한 경량 soap 전송을 위한방법 및 시스템
Rajput et al. Comparing stream control and datagram congestion control with traditional transmission control protocol
WO2023056873A1 (zh) 数据请求方法、通信装置和通信系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12864107

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12864107

Country of ref document: EP

Kind code of ref document: A1