CN108650286A - A kind of implementation method of the server system based on Socket and WebSocket mixed modes - Google Patents
A kind of implementation method of the server system based on Socket and WebSocket mixed modes Download PDFInfo
- Publication number
- CN108650286A CN108650286A CN201810194891.7A CN201810194891A CN108650286A CN 108650286 A CN108650286 A CN 108650286A CN 201810194891 A CN201810194891 A CN 201810194891A CN 108650286 A CN108650286 A CN 108650286A
- Authority
- CN
- China
- Prior art keywords
- client
- websocket
- request
- server
- socket
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a kind of implementation methods of the server system based on Socket and WebSocket mixed modes, are related to the communications field.This system includes three client, proxy server, application server parts.Client is established by Socket and proxy server and is connected first, sends request;Secondly, proxy server forwards a request to application server again;Finally, application server processes are asked, meeting with a response as a result, and result is sent to client by WebSocket.This method realizes the mixing of Socket and WebSocket, and Internet resources and bandwidth are saved in the system with proxy server and improves distribution efficiency.It ensure that under the premise of proxy server performance is unaffected, improve the ability of load balancing.
Description
Technical field
The present invention relates to the communications field, specifically a kind of server system based on Socket and WebSocket mixed modes
The implementation method of system.
Background technology
Communication mode between the client and server system of current main-stream is more single, and the communication of bottom is usually
Socket or WebSocket.Socket provides the ability of network communication, but its more application scenarios is one-way communication,
With the fast development of internet, existing server system architecture has been unable to meet the demand of high concurrent and high availability.And
WebSocket can establish link and mutually send including having smaller heading, client and server-side only to need once to shake hands just
Data and in real time, full duplex the advantages that.There is larger, high requirement network to scale, distribution capability and availability etc.
In communication system, gradually it is intended to use WebSocket as its transmission carrying, load balancing is solved using proxy server
The problem of.But initiate to ask to proxy server since WebSocket is connected to client, then the response of the request is returned
Go to and never disconnect during the client, i.e. the connection occupies always the resource of load balancing apparatus, client and
Data interaction between application server is required for forwarding by load balancing apparatus.Therefore, with the increasing that WebSocket is asked
More, this will cause the continuous decrease of load balancing apparatus self performance, systematic entirety that can abnormally decline, seriously expend net
Network resource.
Invention content
In order to overcome the disadvantages of the above prior art, the present invention provides a kind of mixed based on Socket and WebSocket
The implementation method of the server system of syntype, realizes the advantages of combining two kinds of communication protocol of Socket and WebSocket
High performance server system efficiently solves the above problem, improves system performance, saves Internet resources.
The present invention is realized with following technical solution:A kind of service based on Socket and WebSocket mixed modes
The implementation method of device system includes with the client for sending Socket request functions and generation WebSocket link information functions
It is responsible for receiving the request that client is sent, and forwards requests to idle application according to the working condition of application server in end
Server, at the same forwarding client request after disconnect with the Socket of the client proxy servers connecting and have connect
It receives Proxy request and processing is asked, and the result of processing is directly returned to client functionality without proxy server
Three parts of application server;
Client is established by Socket and proxy server and is connected first, sends request;Secondly, proxy server again will
Request is transmitted to application server;Finally, application server processes are asked, meeting with a response as a result, and passing through result
WebSocket is sent to client.
Preferably, request is sent to be as follows:
(1) client sends Socket requests, while in client according to business demand to proxy server
WebSocket link informations are generated, WebSocket link informations and the relevant parameter of business one are risen
It is sent to proxy server;
(2) after proxy server receives the request that client is sent, the free list of application server is inquired, selects a sky
The request of client and relevant parameter are transmitted to application server by not busy application server;
(3) proxy server is transmitted to after application server to actively close and be connected with the Socket of client.
Preferably, processing request is as follows:
(1) application server receives the request that proxy server forwarding comes;
(2) the WebSocket link informations of relevant parameter and client are obtained with the solution packet mode consulted in advance;
(3) application server obtains the result of processing according to business demand and the processing request of specific required parameter;
(4) application server constructs after the result for obtaining processing according to the WebSocket link informations that client transmits
WebSocket connections return result to client by WebSocket connections.
Compared with prior art scheme, beneficial effects of the present invention:
(1) the advantages of being integrated with prior art scheme;
(2) the advantages of combining two kinds of communication protocol of Socket and WebSocket, realizes high performance server system
System;
(3) system performance is improved, Internet resources are saved.
Description of the drawings
The invention will be further described below in conjunction with the accompanying drawings.
Fig. 1 is the overall structure diagram in the present invention;
Fig. 2 is that request work flow diagram is sent in the present invention;
Fig. 3 is processing request work flow diagram in the present invention;
Fig. 4 is the main packet form schematic diagram of client and proxy server communication in the present invention;
Fig. 5 is the schematic diagram that proxy server searches idle server in the present invention;
Fig. 6 is the unpacking schematic diagram consulted between proxy server and client in the present invention.
Specific implementation mode
As shown in Figure 1, this system includes three client, proxy server, application server parts.Client has hair
It send Socket request functions and generates the function of WebSocket link informations.Proxy server is responsible for receiving what client was sent
Request, and idle application server is forwarded requests to according to the working condition of application server, while proxy server exists
It disconnects after the request of forwarding client and being connect with the Socket of client, save bandwidth resources.Application server, which has, receives generation
The function of managing server request, handles the function of request, and the result of processing is directly returned to visitor without proxy server
The function at family end.
Client is established by Socket and proxy server and is connected first, sends request;Secondly, proxy server again will
Request is transmitted to application server;Finally, application server processes are asked, meeting with a response as a result, and passing through result
WebSocket is sent to client.This method realizes the mixing of Socket and WebSocket, with proxy server
Internet resources and bandwidth are saved in system and improve distribution efficiency.It ensure that before proxy server performance does not receive influence
It puts, improves the ability of load balancing.
As shown in Fig. 2, it is specific as follows to send request workflow:
(1) client sends Socket requests, while generating in client according to business demand to proxy server
WebSocket link informations and the relevant parameter of business are sent collectively to proxy server by WebSocket link informations;
(2) after proxy server receives the request that client is sent, the free list of application server is inquired, selects a sky
The request of client and relevant parameter are transmitted to application server by not busy application server;
(3) proxy server is transmitted to after application server to actively close and be connected with the Socket of client, saves network
Resource improves system performance.
As shown in figure 3, processing request workflow is specific as follows:
(1) application server receives the request that proxy server forwarding comes;
(2) the WebSocket link informations of relevant parameter and client are obtained with the solution packet mode consulted in advance;
(3) application server obtains the result of processing according to business demand and the processing request of specific required parameter;
(4) application server constructs after the result for obtaining processing according to the WebSocket link informations that client transmits
WebSocket connections return result to client by WebSocket connections.
As shown in figure 4, there is the main packet format of client and proxy server communication in the present invention:Current user information,
Business relevant parameter, WebSocket link informations.
As shown in figure 5, proxy server lookup idle server detailed process is as follows:
(1) the application server free list in proxy server is first looked for, according to the utilization rate of CPU and currently processed
Number of tasks is ranked up, using the low server low with number of tasks of CPU usage as idle server, with finding corresponding IP
Location;
(2) after obtaining the IP address of idle server by (1), the request that client is sent is transmitted to corresponding idle clothes
Business device;
(3) after sending request, refresh application server free list, the number of tasks and CPU usage of server are answered in update.
As shown in fig. 6, the solution packet mode consulted between proxy server and client is specific as follows:Client and agency
For the packet format communicated between server in the form of Key-Value, the related service demand of processing is put into Method by client
In this fixed Key, by Method, this Key is worth accordingly when proxy server parses, if client needs to send out
Other additional parameters are given then to be transmitted by Key as Parameter, proxy server is solved also according to corresponding Key
Analyse the value of the inside.
As shown from the above technical solution, this method is integrated with the advantages of prior art scheme, realizes high performance service
Device system improves system performance, saves Internet resources.
Claims (3)
1. a kind of implementation method of the server system based on Socket and WebSocket mixed modes, it is characterised in that:Including
It is sent with sending the client of Socket request functions and generation WebSocket link information functions, being responsible for reception client
Request, and idle application server is forwarded requests to according to the working condition of application server, while in forwarding client
It is disconnected after the request at end with the Socket of the client proxy servers connecting and with the request of Receiving Agent server and place
Reason is asked, and the result of processing is directly returned to three portions of application server of client functionality without proxy server
Point;
Client is established by Socket and proxy server and is connected first, sends request;Secondly, proxy server again will request
It is transmitted to application server;Finally, application server processes are asked, meeting with a response as a result, and result is passed through WebSocket
It is sent to client.
2. a kind of realization of server system based on Socket and WebSocket mixed modes according to claim 1
Method, it is characterised in that:Request is sent to be as follows:
(1) client sends Socket requests, while generating in client according to business demand to proxy server
WebSocket link informations and the relevant parameter of business are sent collectively to proxy server by WebSocket link informations;
(2) after proxy server receives the request of client transmission, inquire the free list of application server, select one it is idle
The request of client and relevant parameter are transmitted to application server by application server;
(3) proxy server is transmitted to after application server to actively close and be connected with the Socket of client.
3. a kind of realization of server system based on Socket and WebSocket mixed modes according to claim 1
Method, it is characterised in that:Processing request is as follows:
(1) application server receives the request that proxy server forwarding comes;
(2) the WebSocket link informations of relevant parameter and client are obtained with the solution packet mode consulted in advance;
(3) application server obtains the result of processing according to business demand and the processing request of specific required parameter;
(4) application server constructs after the result for obtaining processing according to the WebSocket link informations that client transmits
WebSocket connections return result to client by WebSocket connections.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810194891.7A CN108650286A (en) | 2018-03-09 | 2018-03-09 | A kind of implementation method of the server system based on Socket and WebSocket mixed modes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810194891.7A CN108650286A (en) | 2018-03-09 | 2018-03-09 | A kind of implementation method of the server system based on Socket and WebSocket mixed modes |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108650286A true CN108650286A (en) | 2018-10-12 |
Family
ID=63744049
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810194891.7A Pending CN108650286A (en) | 2018-03-09 | 2018-03-09 | A kind of implementation method of the server system based on Socket and WebSocket mixed modes |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108650286A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109922053A (en) * | 2019-02-22 | 2019-06-21 | 北京三快在线科技有限公司 | Data transmission method, device, electronic equipment and readable storage medium storing program for executing |
CN110324397A (en) * | 2019-03-21 | 2019-10-11 | 国网山东省电力公司 | Intelligent substation station level application service interface access method based on Dynamic link library |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103067292A (en) * | 2012-12-26 | 2013-04-24 | 华为技术有限公司 | Websocket-transmission-based load balancing method and device |
US20140092418A1 (en) * | 2012-10-03 | 2014-04-03 | Canon Kabushiki Kaisha | Image forming device, management device, information processing system, and storage medium |
CN107342934A (en) * | 2017-06-19 | 2017-11-10 | 浪潮金融信息技术有限公司 | A kind of mixed mode Mobile solution real-time messages method for pushing and system based on WebSocket |
CN107528891A (en) * | 2017-08-04 | 2017-12-29 | 北京恒信仪和信息技术有限公司 | A kind of automated cluster method and its system based on WebSocket |
-
2018
- 2018-03-09 CN CN201810194891.7A patent/CN108650286A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140092418A1 (en) * | 2012-10-03 | 2014-04-03 | Canon Kabushiki Kaisha | Image forming device, management device, information processing system, and storage medium |
CN103067292A (en) * | 2012-12-26 | 2013-04-24 | 华为技术有限公司 | Websocket-transmission-based load balancing method and device |
CN107342934A (en) * | 2017-06-19 | 2017-11-10 | 浪潮金融信息技术有限公司 | A kind of mixed mode Mobile solution real-time messages method for pushing and system based on WebSocket |
CN107528891A (en) * | 2017-08-04 | 2017-12-29 | 北京恒信仪和信息技术有限公司 | A kind of automated cluster method and its system based on WebSocket |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109922053A (en) * | 2019-02-22 | 2019-06-21 | 北京三快在线科技有限公司 | Data transmission method, device, electronic equipment and readable storage medium storing program for executing |
CN110324397A (en) * | 2019-03-21 | 2019-10-11 | 国网山东省电力公司 | Intelligent substation station level application service interface access method based on Dynamic link library |
CN110324397B (en) * | 2019-03-21 | 2021-09-21 | 国网山东省电力公司 | Intelligent substation station control layer application service interface access method based on dynamic connection |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109088892B (en) | Data transmission method, system and proxy server | |
US9578081B2 (en) | System and method for providing an actively invalidated client-side network resource cache | |
CN112887433B (en) | Cloud access edge service method and system based on QUIC protocol | |
CN107135279B (en) | Method and device for processing long connection establishment request | |
US20150295785A1 (en) | Resource Subscription Method and Device | |
CN103312528B (en) | A kind of heartbeat message sending method and user terminal | |
KR20000057718A (en) | Method and appratus for providing awareness-triggered push | |
US9426767B2 (en) | Method, gateway, proxy and system for implementing mobile internet services | |
CN107528891B (en) | Websocket-based automatic clustering method and system | |
CN101217483A (en) | A method to realize cluster server inner load sharing agent | |
CN102546646B (en) | System and method for realizing voice talkback function | |
US20200099761A1 (en) | Data transmission method, network device, terminal device, and computer readable storage medium | |
CN107979592A (en) | A kind of method and device for sending business request information | |
CN109698785A (en) | A kind of the real-time messages method for pushing and device of distribution high concurrent | |
WO2023221452A1 (en) | Packet processing system and method, device, and storage medium | |
CN111064771A (en) | Network request processing method and system | |
WO2015090225A1 (en) | Linux-based adaptive component communication method | |
CN108650286A (en) | A kind of implementation method of the server system based on Socket and WebSocket mixed modes | |
Xu et al. | Design of oneM2M-based fog computing architecture | |
US11564157B2 (en) | Data transmission method, apparatus and device and computer-readable storage medium | |
WO2020191864A1 (en) | Method, system and device for determining transmission quality of node, and server | |
CN109063140A (en) | A kind of data query method, transfer server and computer readable storage medium | |
CN114827007A (en) | Routing method and device for computing power perception, routing node and client equipment | |
CN114051030B (en) | Communication method, communication device, intelligent community system and storage medium | |
CN109600452B (en) | Server cluster, message pushing method and related server |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20181012 |
|
WD01 | Invention patent application deemed withdrawn after publication |