CN115665222A - Distributed socket data interaction method - Google Patents

Distributed socket data interaction method Download PDF

Info

Publication number
CN115665222A
CN115665222A CN202211286906.5A CN202211286906A CN115665222A CN 115665222 A CN115665222 A CN 115665222A CN 202211286906 A CN202211286906 A CN 202211286906A CN 115665222 A CN115665222 A CN 115665222A
Authority
CN
China
Prior art keywords
socket
server
client
data interaction
request
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
Application number
CN202211286906.5A
Other languages
Chinese (zh)
Inventor
全亚中
胡朝罕
曹良华
何霞仙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHANGHAI TELECOM TECHNOLOGY DEVELOPMENT CO LTD
Original Assignee
SHANGHAI TELECOM TECHNOLOGY DEVELOPMENT CO LTD
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 SHANGHAI TELECOM TECHNOLOGY DEVELOPMENT CO LTD filed Critical SHANGHAI TELECOM TECHNOLOGY DEVELOPMENT CO LTD
Priority to CN202211286906.5A priority Critical patent/CN115665222A/en
Publication of CN115665222A publication Critical patent/CN115665222A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Multi Processors (AREA)

Abstract

The invention relates to a distributed socket data interaction method, which comprises the following steps: establishing a plurality of socket servers, connecting the socket servers with a background server, and connecting the socket clients with the socket servers; the socket server side obtains a request of the socket client side and sends the request to the background server; and the background server processes the request and outputs a corresponding processing structure to the socket server, and the socket server distributes a processing result to a corresponding socket client. The invention effectively solves the problems of complex operation and higher cost of the traditional data interaction mode, reduces the difficulty of data interaction, shortens the interaction time, accelerates the interaction speed and improves the interaction efficiency by optimizing the data interaction mode.

Description

Distributed socket data interaction method
Technical Field
The invention relates to the technical field of computers, in particular to a distributed socket data interaction method.
Background
In the internet of things mode, a traditional front-end and back-end interaction mode cannot meet real-time pushing of a device data protocol, in the traditional mode, a client and a server cannot always communicate, a reliable and perfect disconnected network automatic reconnection mechanism service framework is needed, the framework is complex in structure and operation, the quality of service (QPS) of data protocol interaction in the traditional mode is not high, and cost is high.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides a distributed socket data interaction method, solves the problems of complex operation and higher cost of the traditional data interaction mode, and reduces the difficulty of data interaction, shortens the interaction time, accelerates the interaction speed and improves the interaction efficiency by optimizing the data interaction mode.
The technical scheme for realizing the purpose is as follows:
the invention provides a distributed socket data interaction method, which comprises the following steps:
establishing a plurality of socket servers, connecting the socket servers with a background server, and connecting the socket clients with the socket servers;
the socket server side obtains a request of the socket client side and sends the request to the background server;
and the background server processes the request and outputs a corresponding processing structure to the socket server, and the socket server distributes a processing result to a corresponding socket client.
The invention provides a distributed socket data interaction method, which is characterized in that a socket client is connected with a socket server, so that the socket client and the socket server can establish communication, and a background server distributes processing results to corresponding socket clients through the socket server, so that the problems of complex operation and higher cost of the traditional data interaction mode are solved, and the difficulty of data interaction is reduced, the interaction time is shortened, the interaction speed is accelerated, and the interaction efficiency is improved by optimizing the data interaction mode.
The distributed socket data interaction method is further improved in that when the socket client side and the socket server side are connected, the method further comprises the following steps:
the Socket client establishes connection with the Socket server through the channel, carries out IP white list verification on the Socket client, and if the IP white list verification passes, the Socket server is connected with the Socket client.
The distributed socket data interaction method is further improved in that when the socket client registers, the method further comprises the following steps:
and obtaining a socket server corresponding to the target background server through hash calculation, and connecting the socket client with the socket server.
The distributed socket data interaction method is further improved in that when a socket client needs to replace a socket server, the method further comprises the following steps:
and sending a message to each socket server to find out the socket server holding the session information of the socket client through the hash, and connecting the socket server with the socket client.
The distributed socket data interaction method is further improved in that when a socket server holding session information of a socket client is searched, the method further comprises the following steps:
and inquiring whether the cache of the socket server has the session information of the socket client or not, and if the socket server has the session information of the socket client, connecting the socket server with the socket client.
The distributed socket data interaction method is further improved in that the method further comprises the following steps:
the method comprises the steps that a request sent by a socket client side is encrypted and then sent to a socket server side, and the socket server side decrypts the request and then sends the request to a background server.
The distributed socket data interaction method is further improved in that the method further comprises the following steps:
the socket server monitors the online and offline of all connected socket clients, and when online or offline information of the socket clients is received, the socket server sends the online or offline information to all connected socket clients.
The distributed socket data interaction method is further improved in that the method further comprises the following steps:
the socket server side distributes the information sent by the background server to the corresponding socket client side through the channel.
The distributed socket data interaction method is further improved in that the method further comprises the following steps:
and carrying out peak clipping and valley filling on the request sent by the socket client through the EventBus message bus so as to buffer the request.
Drawings
FIG. 1 is a flowchart of a distributed socket data interaction method according to the present invention.
Detailed Description
The invention is further described with reference to the following figures and specific examples.
Referring to fig. 1, the distributed socket data interaction method provided by the invention is characterized in that a socket client is connected with a socket server, so that the socket client and the socket server can establish communication, and a background server distributes a processing result to a corresponding socket client through the socket server, so that the problems of complex operation and high cost of the traditional data interaction mode are solved, and the difficulty of data interaction is reduced, the interaction time is shortened, the interaction speed is accelerated, and the interaction efficiency is improved by optimizing the data interaction mode. The distributed socket data interaction method of the invention is explained below with reference to the accompanying drawings.
Referring to fig. 1, a flow chart of the distributed socket data interaction method of the present invention is shown. The distributed socket data interaction method of the present invention is described below with reference to fig. 1.
As shown in fig. 1, the present invention provides a distributed socket data interaction method, which includes the following steps:
establishing a plurality of socket servers, connecting the socket servers with a background server, and connecting the socket clients with the socket servers;
the socket server side obtains a request of the socket client side and sends the request to the background server;
and the background server processes the request and outputs a corresponding processing structure to the socket server, and the socket server distributes a processing result to a corresponding socket client.
Further, the method also comprises the following steps:
the method comprises the steps that a request sent by a socket client side is encrypted and then sent to a socket server side, and the socket server side decrypts the request and then sends the request to a background server.
Specifically, still include:
the socket server monitors the online and offline of all connected socket clients, and when the online or offline information of the socket clients is received, the socket server sends the online or offline information to all connected socket clients.
Specifically, still include:
the socket server side distributes the information sent by the background server to the corresponding socket client side through the channel.
Preferably, the method further comprises the following steps:
and carrying out peak clipping and valley filling on the request sent by the socket client through the EventBus message bus so as to buffer the request.
As a preferred embodiment of the present invention, when connecting the socket client and the socket server, the method further includes:
the socket client establishes connection with the socket server through a channel, carries out IP white list verification on the socket client, and if the IP white list verification passes, the socket server is connected with the socket client.
Further, when registering, the socket client further includes:
and obtaining a socket server corresponding to the target background server through hash calculation, wherein the socket client is connected with the socket server.
Further, when the socket client needs to replace the socket server, the method further comprises:
and sending a message to each socket server to find out the socket server holding the session information of the socket client through the hash, and connecting the socket server with the socket client.
Specifically, when a socket server holding session information of a socket client is found, the method further includes:
and querying whether the cache of the socket server has the session information of the socket client or not, and if so, connecting the socket server with the socket client.
The specific embodiment of the invention is as follows:
establishing a plurality of socket servers, connecting the socket servers with the background servers, registering a socket client, obtaining the socket server corresponding to the target background server through hash calculation, connecting the socket client with the socket server, and starting a new socket session to register to one of the socket servers once the socket client is refreshed;
when the socket client is connected with the socket server, performing IP white list verification on the socket client, and if the IP white list verification is passed, connecting the socket server with the socket client;
the socket client sends out a request, peak clipping and valley filling are carried out through an EventBus message bus, so that information is buffered, the pressure that a background server receives a large number of messages at the same time is relieved, the request is sent to the socket server after being encrypted, and the socket server sends the request to the background server after decrypting the request;
the background service area processes the request and outputs a corresponding processing result to the socket server, and the socket server distributes the processing result to a corresponding socket client through a channel to realize point-to-point and subscription message distribution;
the socket server monitors the online and offline of all connected socket clients, and when online or offline information of the socket clients is received, the socket server sends the online or offline information to all connected socket clients;
when the socket client needs to replace the socket server, sending a message to each socket server so as to find out the socket server holding the session information of the socket client through the hash;
the socket server subscribes the same address by using a pub/sub mode of Redis, and after receiving the message, the socket server inquires whether the session information of the socket client exists in the cache of the socket server;
the hash forwarding mode can be provided by rewriting the request forwarding of the network management, the spring closed gateway and the nacos can be used, the hash calculation during message sending is consistent with the hash forwarding algorithm provided by the nacos, the hash algorithm is controlled by the RPC mode among services, the message forwarding is carried out by using the rabbitmq, the rabbitmq provides a mechanism for producing ACK (acknowledgement) and a mechanism for consuming ACK (acknowledgement), the data can be ensured not to be lost, and when the socket server fails in sending, the data can be kept in the rabbitmq;
and connecting the new socket server with the socket client.
While the present invention has been described in detail and with reference to the embodiments thereof as shown in the accompanying drawings, it will be apparent to one skilled in the art that various changes and modifications can be made therein. Therefore, certain details of the embodiments are not to be interpreted as limiting, and the scope of the invention is to be determined by the appended claims.

Claims (9)

1. A distributed socket data interaction method is characterized by comprising the following steps:
establishing a plurality of socket servers, connecting the socket servers with a background server, and connecting a plurality of socket clients with the socket servers;
the socket server side obtains a request of the socket client side and sends the request to the background server;
the background server processes the request and outputs a corresponding processing result to the socket server, and the socket server distributes the processing result to the corresponding socket client.
2. The distributed socket data interaction method of claim 1, wherein when connecting the socket client and the socket server, the method further comprises:
the socket client establishes connection with the socket server through a channel, carries out IP white list verification on the socket client, and if the IP white list verification is passed, the socket server is connected with the socket client.
3. The distributed socket data interaction method of claim 1, wherein when registering, the socket client further comprises:
and calculating through a gateway hash to obtain a socket server corresponding to the target background server, wherein the socket client is connected with the socket server.
4. The distributed socket data interaction method of claim 1, wherein when the socket client needs to replace the socket server, the method further comprises:
and sending a message to each socket server to find out the socket server holding the session information of the socket client through the hash, and connecting the socket server with the socket client.
5. The distributed socket data interaction method of claim 4, wherein when a socket server holding session information of the socket client is found, the method further comprises:
and inquiring whether the cache of the socket server side has the session information of the socket client side or not, and if the socket server side has the session information of the socket client side, connecting the socket server side with the socket client side.
6. The distributed socket data interaction method of claim 1, further comprising:
and encrypting the request sent by the socket client and sending the encrypted request to the socket server, and decrypting the request and sending the decrypted request to the background server by the socket server.
7. The distributed socket data interaction method of claim 1, further comprising:
the socket server monitors the online and offline of all the connected socket clients, and when online or offline information of the socket clients is received, the socket server sends the online or offline information to all the connected socket clients.
8. The distributed socket data interaction method of claim 1, further comprising:
and the socket server side distributes the information sent by the background server to the corresponding socket client side through a channel.
9. The distributed socket data interaction method of claim 1, further comprising:
and carrying out peak clipping and valley filling on the request sent by the socket client through an EventBus message bus so as to buffer the request.
CN202211286906.5A 2022-10-20 2022-10-20 Distributed socket data interaction method Pending CN115665222A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211286906.5A CN115665222A (en) 2022-10-20 2022-10-20 Distributed socket data interaction method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211286906.5A CN115665222A (en) 2022-10-20 2022-10-20 Distributed socket data interaction method

Publications (1)

Publication Number Publication Date
CN115665222A true CN115665222A (en) 2023-01-31

Family

ID=84989532

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211286906.5A Pending CN115665222A (en) 2022-10-20 2022-10-20 Distributed socket data interaction method

Country Status (1)

Country Link
CN (1) CN115665222A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140082150A1 (en) * 2012-09-17 2014-03-20 Tencent Technology (Shenzhen) Company Limited Method of establishing a network socket with a data server
US20150334182A1 (en) * 2012-12-17 2015-11-19 Beijing Qihoo Technology Limited System, Method and Browser Client for Enabling Browser Data Synchronization
CN110958240A (en) * 2019-11-27 2020-04-03 北京数知科技股份有限公司 Message subscription system and method
CN112769837A (en) * 2021-01-13 2021-05-07 北京洛塔信息技术有限公司 Websocket-based communication transmission method, device, equipment, system and storage medium
CN113132477A (en) * 2021-04-16 2021-07-16 易斌 Real-time transmission interaction method and system for browser terminal and equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140082150A1 (en) * 2012-09-17 2014-03-20 Tencent Technology (Shenzhen) Company Limited Method of establishing a network socket with a data server
US20150334182A1 (en) * 2012-12-17 2015-11-19 Beijing Qihoo Technology Limited System, Method and Browser Client for Enabling Browser Data Synchronization
CN110958240A (en) * 2019-11-27 2020-04-03 北京数知科技股份有限公司 Message subscription system and method
CN112769837A (en) * 2021-01-13 2021-05-07 北京洛塔信息技术有限公司 Websocket-based communication transmission method, device, equipment, system and storage medium
CN113132477A (en) * 2021-04-16 2021-07-16 易斌 Real-time transmission interaction method and system for browser terminal and equipment

Similar Documents

Publication Publication Date Title
CN101540775B (en) Method and device for distributing contents and network system for distributing contents
EP2892209B1 (en) Method, apparatus, and system for transmitting media data based on OTT
US9003491B2 (en) Secure push and status communication between client and server
US8086846B2 (en) Providing non-proxy TLS/SSL support in a content-based load balancer
US7913293B2 (en) Method and communication unit for communicating between communication apparatuses
US20070274525A1 (en) Encrypted communication system, communication status management server, encrypted communication method, and communication status management method
WO2017161762A1 (en) Data transmission method, device and system
JPH07107083A (en) Cipher communication system
WO2023000940A1 (en) Data processing method and apparatus, and network element device, storage medium and program product
WO2015120766A1 (en) Video optimisation system and method
US7673136B2 (en) Method for secure multicast repeating on the public Internet
US20100106962A1 (en) Method, apparatus, and system for managing multimedia services
CN113475084B (en) Multicast assisted delivery
WO2023000936A1 (en) Data processing method, function device and readable storage medium
CN111683158B (en) MQTT protocol communication method for realizing synchronous request response
US20160212102A1 (en) Method and device for distributing traffic by using plurality of network interfaces in wireless communication system
CN105005500A (en) Remote procedure calling method, server side and client
CN111741129A (en) MQTT protocol communication method and system for realizing multiplexing
CN101854332B (en) Method, device and system for processing streaming service
CN115665222A (en) Distributed socket data interaction method
CN110380967B (en) SSE technology-based server message pushing method
CN101175038B (en) Data stream information transmission method, communication system and equipment
US20130024543A1 (en) Methods for generating multiple responses to a single request message and devices thereof
CN114363204A (en) Request monitoring method, network device and storage medium
CN112751842A (en) High-performance instant messaging method

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