CN113452765A - Long-connection communication method, system, device, storage medium and program product - Google Patents

Long-connection communication method, system, device, storage medium and program product Download PDF

Info

Publication number
CN113452765A
CN113452765A CN202110686693.4A CN202110686693A CN113452765A CN 113452765 A CN113452765 A CN 113452765A CN 202110686693 A CN202110686693 A CN 202110686693A CN 113452765 A CN113452765 A CN 113452765A
Authority
CN
China
Prior art keywords
target
long
server
long connection
connection
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.)
Granted
Application number
CN202110686693.4A
Other languages
Chinese (zh)
Other versions
CN113452765B (en
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110686693.4A priority Critical patent/CN113452765B/en
Publication of CN113452765A publication Critical patent/CN113452765A/en
Application granted granted Critical
Publication of CN113452765B publication Critical patent/CN113452765B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
    • 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
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Abstract

The present disclosure relates to a long connection communication method, system, electronic device, storage medium and program product, wherein the method comprises: acquiring a long-connection storage server; storing key-value pairs between the target client and the long-connection target server in the long-connection storage server; acquiring a target key value pair corresponding to a target service message from a long-connection storage server; and forwarding the target service message to the target client according to the target key value pair and the long connection link. The present disclosure stores key-value pairs between a target client and a long-connection target server within a long-connection server cluster. Namely, the long connection storage server in the long connection server cluster is used as a storage node, and the storage node is used for storing the key value pair between the target client and the long connection target server, so that the key value pair is prevented from being stored in a third-party storage center, the risk that a long connection link between the target client and the long connection target server is leaked is reduced, and the consumption of operation cost is reduced.

Description

Long-connection communication method, system, device, storage medium and program product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a long connection communication method, system, electronic device, computer-readable storage medium, and computer program product.
Background
Currently, more and more service systems need to maintain long connection between a client and a server, so that the server can sense the up-down state of the client in real time, and the server can actively push service messages to the client.
In the related art, a long-connection management scheme needs to store key value pairs between a client and a server by means of a third-party storage center, so that the reliability requirement on the third-party storage center is high, if the third-party storage center fails, long connection between the client and the server in the whole service system is affected, the risk of long connection between the client and the server is high, and in addition, the key value pairs are stored in the third-party storage center, so that more operation cost is consumed.
Disclosure of Invention
The present disclosure provides a long connection communication method, system, electronic device, computer-readable storage medium, and computer program product to at least solve the problems of high risk and high operation cost of long connection in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a long connection communication method, where a long connection link is maintained between a target client and a long connection target server in a long connection server cluster, the method including: acquiring a long connection storage server from the long connection server cluster; storing a key-value pair between the target client and the long-connection target server in the long-connection storage server, wherein the key-value pair comprises identification information of the target client and address information of the long-connection target server; receiving a target service message; acquiring a target key value pair corresponding to the target service message from the long-connection storage server; and forwarding the target service message to the target client according to the target key value pair and the long connection link.
Optionally, the forwarding the target service message to the target client according to the target key-value pair and the long connection link includes: acquiring a current long connection server from the long connection server cluster according to a preset scheduling algorithm; and if the long connection link is kept between the target client corresponding to the target service message and the current long connection server, forwarding the target service message to the target client according to the long connection link.
Optionally, the obtaining the target key-value pair corresponding to the target service message from the long connection storage server includes: and if the target client corresponding to the target service message does not maintain the long connection link with the current long connection server, acquiring a target key value pair corresponding to the target service message from the long connection storage server.
Optionally, the forwarding the target service message to the target client according to the target key-value pair and the long connection link includes: if the address information in the target key value pair is different from the address information of the current long connection server, forwarding the target service message to the long connection target server, and forwarding the target service message from the long connection target server to the target client through the long connection link.
Optionally, the method further comprises: and if the address information in the target key value pair is the same as the address information of the current long connection server and the long connection link is not kept between the target client corresponding to the target service message and the current long connection server, returning prompt information indicating that the target client is offline.
Optionally, the method further comprises: and when the number of the long connection servers in the long connection server cluster is changed, carrying out re-hashing operation on the key value pairs stored in each long connection server in the long connection server cluster.
Optionally, the obtaining a long connection storage server from the long connection server cluster includes: and acquiring the long-connection storage server from the long-connection server cluster based on a consistent hash algorithm.
According to a second aspect of the embodiments of the present disclosure, there is provided a long connection communication system, in which a long connection link is maintained between a target client and a long connection target server in a long connection server cluster, the system including: an acquisition unit configured to perform acquisition of a long-connection storage server from the long-connection server cluster; a storage unit configured to perform storing, in the long-connection storage server, a key-value pair between the target client and the long-connection target server, the key-value pair containing identification information of the target client and address information of the long-connection target server; a receiving unit configured to perform receiving a target service message; the obtaining unit is further configured to perform obtaining a target key value pair corresponding to the target service message from the long connection storage server; a forwarding unit configured to perform forwarding the target service message to the target client according to the target key-value pair and the long connection link.
Optionally, the forwarding unit includes: the server acquisition unit is configured to execute the acquisition of the current long connection server from the long connection server cluster according to a preset scheduling algorithm; and the message forwarding unit is configured to forward the target service message to the target client according to the long connection link if the long connection link is maintained between the target client corresponding to the target service message and the current long connection server.
Optionally, the obtaining unit is configured to perform, if the target client corresponding to the target service message does not maintain the long connection link with the current long connection server, obtaining, from the long connection storage server, a target key value pair corresponding to the target service message.
Optionally, the forwarding unit is configured to forward the target service message to the long connection target server and forward the target service message from the long connection target server to the target client through the long connection link if the address information in the target key value pair is different from the address information of the current long connection server.
Optionally, the system further comprises: a returning unit, configured to execute returning prompt information indicating that the target client is offline if the address information in the target key value pair is the same as the address information of the current long connection server, and the target client corresponding to the target service message does not maintain the long connection link with the current long connection server.
Optionally, the system further comprises: a hashing unit configured to perform a rehashing operation on the key-value pair stored in each long-connection server in the long-connection server cluster when the number of long-connection servers in the long-connection server cluster is changed.
Optionally, the obtaining unit is configured to perform obtaining the long connection storage server from the long connection server cluster based on a consistent hashing algorithm. According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the long connection communication method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the long connection communication method according to the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the long connection communication method of the first aspect described above.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the embodiment of the disclosure provides a long connection communication scheme, which relates to a target client and a long connection server cluster. The long connection link is maintained between the target client and the long connection target server in the long connection server cluster, and the embodiment of the disclosure can acquire the long connection storage server from the long connection server cluster, and further store the key value pair between the target client and the long connection target server into the long connection storage server. After receiving the target service message, the target key value pair corresponding to the target service message may be acquired from the long connection storage server, and the target service message may be forwarded to the target client. Embodiments of the present disclosure store key-value pairs between a target client maintaining a long connection link and a long connection target server within a long connection server cluster. Namely, the long connection storage server in the long connection server cluster is used as a storage node, and the storage node is used for storing the key value pair between the target client and the long connection target server, so that the key value pair is prevented from being stored in a third-party storage center, the risk that a long connection link between the target client and the long connection target server is leaked is reduced, and the consumption of operation cost is reduced.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flow chart illustrating a long connection communication method in accordance with an example embodiment.
Fig. 2 is a flow diagram illustrating an arbitrary long connection server forwarding a target traffic message to a target client, either directly or indirectly, according to an example embodiment.
Fig. 3 is a schematic diagram illustrating an establishment procedure of a long connection server cluster according to an exemplary embodiment.
Fig. 4 is a flow diagram illustrating a target client establishing a long connection link with a long connection target server in accordance with an example embodiment.
Fig. 5 is a block diagram illustrating a long connection communication system in accordance with an exemplary embodiment.
Fig. 6 is a block diagram illustrating a long-connection communication system in accordance with an example embodiment.
Fig. 7 is a block diagram illustrating a long connection communications electronic device in accordance with an example embodiment.
Fig. 8 is a block diagram illustrating another long-connection communications electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flow diagram illustrating a long-connection communication method according to an example embodiment, which may involve a target client and a long-connection server cluster, as shown in fig. 1, wherein the long-connection server cluster may contain a plurality of long-connection servers. The target client can be any client, and the long connection target server can be any long connection server in the long connection server cluster. In practical application, the target client may be connected to any long connection server in the long connection server cluster through a variety of scheduling algorithms or third party load balancing. The target client maintains a long connection link with a long connection target server in the long connection server cluster.
The long-connection communication method shown in fig. 1 may specifically include the following steps.
In step S11, a long-connection storage server is acquired from the long-connection server cluster.
In the embodiment of the present disclosure, the long connection server in the long connection server cluster may also serve as a storage node, that is, the long connection storage server may be selected from the long connection server cluster, and the long connection storage server is used as the storage node. That is, the storage nodes are located inside a long-connection server cluster. In practical application, the long-connection storage server can be acquired from the long-connection server cluster based on a consistent hashing algorithm.
In step S12, the key-value pair between the target client and the long-connection target server is stored in the long-connection storage server.
In an embodiment of the present disclosure, the key-value pair between the target client and the long connection target server may include identification information of the target client and address information of the long connection target server. Moreover, the identification information of the target client and the address information of the long connection target server are combined into a key value pair, that is, the identification information of the target client and the address information of the long connection target server appear in pairs. The long-connection storage server serves as a storage node, and key value pairs can be stored in the storage node.
In step S13, a target service message is received.
In the embodiment of the present disclosure, a target service message of a service system may be received, where the target service message is used to be sent from the service system to a target client. In practical applications, the target service message may contain identification information of the target client.
In step S14, the target key-value pair corresponding to the target service message is acquired from the long-connection storage server.
In the embodiment of the present disclosure, if the target service message is to be forwarded to the target client, the target service message needs to be transmitted through the long connection link between the long connection target server and the target client. Therefore, the target key value pair can be acquired from the storage node, namely the address information of the long connection target server establishing the long connection link with the target client is acquired from the storage node
In step S15, the target service message is forwarded to the target client according to the target key-value pair and the long connection link.
In the embodiment of the present disclosure, after the target key value pair is acquired, that is, after the address information of the long connection target server maintaining the long connection link with the target client is acquired, the target service message may be transmitted to the target client through the long connection link between the long connection target server and the target client. Thus, the process that the target service message of the service system is forwarded to the target client through the long connection server cluster is completed.
The embodiment of the disclosure provides a long connection communication scheme, which relates to a target client and a long connection server cluster. The long connection link is maintained between the target client and the long connection target server in the long connection server cluster, and the embodiment of the disclosure can acquire the long connection storage server from the long connection server cluster, and further store the key value pair between the target client and the long connection target server into the long connection storage server. After receiving the target service message, the target key value pair corresponding to the target service message may be acquired from the long connection storage server, and the target service message may be forwarded to the target client. Embodiments of the present disclosure store key-value pairs between a target client maintaining a long connection link and a long connection target server within a long connection server cluster. Namely, the long connection storage server in the long connection server cluster is used as a storage node, and the storage node is used for storing the key value pair between the target client and the long connection target server, so that the key value pair is prevented from being stored in a third-party storage center, the risk that a long connection link between the target client and the long connection target server is leaked is reduced, and the consumption of operation cost is reduced.
In an exemplary embodiment of the present disclosure, referring to fig. 2, fig. 2 shows a flowchart of directly or indirectly forwarding a target service message to a target client by an arbitrary long connection server. One implementation manner of forwarding the target service message to the target client according to the target key value pair and the long connection link is that any long connection server in the long connection server cluster may directly or indirectly forward the target service message to the target client. Therefore, the current long connection server can be acquired from the long connection server cluster according to a preset scheduling algorithm, and the target service message is sent to the current long connection server. The current long connection server may be any long connection server. In practical applications, the preset scheduling algorithm may include, but is not limited to: polling algorithm, right-based polling algorithm, hash algorithm, and the like. And then judging whether a target client corresponding to the target service message keeps a long connection link with the current long connection server, if so, directly forwarding the target service message to the target client according to the long connection link. If a long connection link is not maintained between the target client corresponding to the target service message and the current long connection server, the long connection storage server storing the key value pair of the target client and the long connection target server can be obtained, and then the target key value pair is obtained from the long connection storage server, and specifically, the address information of the long connection target server in the target key value pair can be obtained.
In an exemplary embodiment of the present disclosure, after the target key-value pair is obtained from the long-connection storage server, it may be further determined whether the current long-connection server is the long-connection target server according to the target key-value pair. Specifically, it may be determined whether the address information in the target key value pair is the same as the address information of the current long connection server. If the address information in the target key value pair is the same as the address information of the current long connection server, determining that the current long connection server is the long connection target server; if the address information in the target key value pair is not the same as the address information of the current long connection server, it may be determined that the current long connection server is not the long connection target server.
If the current long connection server is a long connection target server, but the target client corresponding to the target service message is determined before, and a long connection link is not kept between the target client and the current long connection server, the target client can be determined to be in an offline state, and then prompt information indicating that the target client is offline is returned to the current long connection server, and then the prompt information is returned to the service system through the current long connection server.
If the current long connection target server is not the long connection target server, the target service message can be forwarded to the long connection target server according to the address information of the long connection target server in the target key value pair, and the target service message is forwarded to the target client from the long connection target server through the long connection link.
In an exemplary embodiment of the present disclosure, referring to fig. 3, fig. 3 shows a schematic diagram of an establishment flow of a long connection server cluster. The long connection server cluster can register all the long connection servers to a third-party service registration center, and monitor whether the long connection servers change or not through the third-party service registration center. If the number of the long connection servers in the long connection server cluster is changed, the key value pairs stored in the long connection servers can be hashed again; if the number of long connection servers in the long connection server cluster is not changed, no other operation may be performed. It should be noted that, in addition to registering the long-connection server in the long-connection server cluster with the service registry of the third party, the long-connection server in the long-connection server cluster may also be registered with a service registry (e.g., a long-connection registry server) in the long-connection server cluster. The long-connection registration server may be selected from a plurality of long-connection servers of a long-connection server cluster. Embodiments of the present disclosure do not specifically limit the location of the service registry of the long connection server within the long connection server cluster or at the third party server.
In an exemplary embodiment of the present disclosure, referring to fig. 4, fig. 4 shows a flowchart illustrating a target client establishing a long connection link with a long connection target server. The target client can be connected to the long-connection target server through a scheduling algorithm or third-party load balancing. The long connection target server may maintain a long connection link with the target client. And then, acquiring a storage node from the long connection server cluster through a consistent hash algorithm, and storing a key value pair between the target client and the long connection target server into the storage node.
Based on the above description of an embodiment of a long-connection communication method, a long-connection communication system is described below. Referring to fig. 5, fig. 5 shows a schematic diagram of a long connection communication system. The long connection communication system may include a long connection server Cluster (Cluster), which may include five long connection servers, which are nodes S1, S2, S3, S4, and S5, respectively, and the five long connection servers may communicate with each other. Each long connection server provides long connection link management functions and Key-Value pair (K-V) storage services. Each long connection server is registered with a service registry. Any client (Agents) may connect to any of the five long connection servers. The long connection server connected with the client can store the key value pairs on the storage nodes, and particularly, the storage nodes can be obtained through calculation of a consistent hash algorithm.
Fig. 6 is a block diagram illustrating a long-connection communication system in accordance with an example embodiment. The system may involve a target client with a long-connection server cluster, where the long-connection server cluster may contain a plurality of long-connection servers. The target client can be any client, and the long connection target server can be any long connection server in the long connection server cluster. In practical application, the target client may be connected to any long connection server in the long connection server cluster through a variety of scheduling algorithms or third party load balancing. The target client maintains a long connection link with a long connection target server in the long connection server cluster, and the system may specifically include the following units.
An obtaining unit 61 configured to perform obtaining a long-connection storage server from the long-connection server cluster;
a storage unit 62 configured to perform storing, in the long-connection storage server, a key-value pair between the target client and the long-connection target server, the key-value pair containing identification information of the target client and address information of the long-connection target server;
a receiving unit 63 configured to perform receiving a target service message;
the obtaining unit 61 is further configured to perform obtaining a target key value pair corresponding to the target service message from the long connection storage server;
a forwarding unit 64 configured to perform forwarding the target traffic message to the target client according to the target key-value pair and the long connection link.
In an exemplary embodiment of the present disclosure, the forwarding unit 64 includes:
the server acquisition unit is configured to execute the acquisition of the current long connection server from the long connection server cluster according to a preset scheduling algorithm;
and the message forwarding unit is configured to forward the target service message to the target client according to the long connection link if the long connection link is maintained between the target client corresponding to the target service message and the current long connection server.
In an exemplary embodiment of the disclosure, the obtaining unit 61 is configured to perform, if the target client corresponding to the target service message does not maintain the long connection link with the current long connection server, obtaining a target key value pair corresponding to the target service message from the long connection storage server.
In an exemplary embodiment of the disclosure, the forwarding unit 64 is configured to forward the target service message to the long connection target server and forward the target service message from the long connection target server to the target client through the long connection link if the address information in the target key value pair is not the same as the address information of the current long connection server.
In an exemplary embodiment of the present disclosure, the system further includes:
a returning unit, configured to execute returning prompt information indicating that the target client is offline if the address information in the target key value pair is the same as the address information of the current long connection server, and the target client corresponding to the target service message does not maintain the long connection link with the current long connection server.
In an exemplary embodiment of the present disclosure, the system further includes:
a hashing unit configured to perform a rehashing operation on the key-value pair stored in each long-connection server in the long-connection server cluster when the number of long-connection servers in the long-connection server cluster is changed.
In an exemplary embodiment of the disclosure, the obtaining unit 61 is configured to execute obtaining the long connection storage server from the long connection server cluster based on a consistent hashing algorithm.
With regard to the system in the above-described embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 7 is a block diagram illustrating a long connection communications electronic device 700, according to an example embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 7, electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power component 706, a multimedia component 708, an audio component 710, an input/output (I/O) interface 712, a sensor component 714, and a communication component 716.
The processing component 702 generally controls overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to perform all or a portion of the steps of the long-connection communication method described above. Further, the processing component 702 may include one or more modules that facilitate interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate interaction between the multimedia component 708 and the processing component 702.
The memory 704 is configured to perform operations to store various types of data to support operations at the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phonebook data, messages, images, videos, and so forth. The memory 704 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 706 provides power to the various components of the electronic device 700. The power components 706 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 700.
The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 700 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 710 is configured to perform outputting and/or inputting audio signals. For example, the audio component 710 may include a Microphone (MIC) configured to perform receiving external audio signals when the electronic device 700 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 704 or transmitted via the communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.
The I/O interface 712 provides an interface between the processing component 702 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 may detect an open/closed state of the electronic device 700, the relative positioning of components, such as a display and keypad of the electronic device 700, the sensor assembly 714 may also detect a change in the position of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, orientation or acceleration/deceleration of the electronic device 700, and a change in the temperature of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 716 is configured to perform communications that facilitate wired or wireless means between the electronic device 700 and other devices. The electronic device 700 may access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described long-connection communication methods.
In an exemplary embodiment, a computer-readable storage medium comprising instructions, such as the memory 704 comprising instructions, executable by the processor 720 of the electronic device 700 to perform the long-connection communication method described above is also provided. Alternatively, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by the processor 720 of the electronic device 700 to perform the above-described long-connection communication method. Alternatively, the computer program may be stored in a computer readable storage medium of the electronic device 700, which may be a non-transitory computer readable storage medium, for example, ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
Fig. 8 is a block diagram illustrating another long-connection communications electronic device 800 in accordance with an example embodiment. For example, the electronic device 800 may be provided as a server. Referring to fig. 8, electronic device 800 includes a processing component 822, which further includes one or more processors, and memory resources, represented by memory 832, for storing instructions, such as applications, that are executable by processing component 822. The application programs stored in memory 832 may include one or more modules that each correspond to a set of instructions. Further, the processing component 822 is configured to execute instructions to perform the long-connection communication method described above.
The electronic device 800 may also include a power component 826 configured to perform power management of the electronic device 800, a wired or wireless network interface 850 configured to perform connecting the electronic device 800 to a network, and an input/output (I/O) interface 858. The electronic device 800 may operate based on an operating system stored in the memory 832, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A long connection communication method, wherein a long connection link is maintained between a target client and a long connection target server in a long connection server cluster, the method comprising:
acquiring a long connection storage server from the long connection server cluster;
storing a key-value pair between the target client and the long-connection target server in the long-connection storage server, wherein the key-value pair comprises identification information of the target client and address information of the long-connection target server;
receiving a target service message;
acquiring a target key value pair corresponding to the target service message from the long-connection storage server;
and forwarding the target service message to the target client according to the target key value pair and the long connection link.
2. The method of claim 1, wherein forwarding the target traffic message to the target client according to the target key-value pair and the long connection link comprises:
acquiring a current long connection server from the long connection server cluster according to a preset scheduling algorithm;
and if the long connection link is kept between the target client corresponding to the target service message and the current long connection server, forwarding the target service message to the target client according to the long connection link.
3. The method of claim 2, wherein the obtaining the target key-value pair corresponding to the target service message from the long-connection storage server comprises:
and if the target client corresponding to the target service message does not maintain the long connection link with the current long connection server, acquiring a target key value pair corresponding to the target service message from the long connection storage server.
4. The method of claim 3, wherein forwarding the target traffic message to the target client according to the target key-value pair and the long connection link comprises:
if the address information in the target key value pair is different from the address information of the current long connection server, forwarding the target service message to the long connection target server, and forwarding the target service message from the long connection target server to the target client through the long connection link.
5. The method of claim 4, further comprising:
and if the address information in the target key value pair is the same as the address information of the current long connection server and the long connection link is not kept between the target client corresponding to the target service message and the current long connection server, returning prompt information indicating that the target client is offline.
6. The method of claim 1, further comprising:
and when the number of the long connection servers in the long connection server cluster is changed, carrying out re-hashing operation on the key value pairs stored in each long connection server in the long connection server cluster.
7. A long connection communication system wherein a long connection link is maintained between a target client and a long connection target server in a cluster of long connection servers, the system comprising:
an acquisition unit configured to perform acquisition of a long-connection storage server from the long-connection server cluster;
a storage unit configured to perform storing, in the long-connection storage server, a key-value pair between the target client and the long-connection target server, the key-value pair containing identification information of the target client and address information of the long-connection target server;
a receiving unit configured to perform receiving a target service message;
the obtaining unit is further configured to perform obtaining a target key value pair corresponding to the target service message from the long connection storage server;
a forwarding unit configured to perform forwarding the target service message to the target client according to the target key-value pair and the long connection link.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the long-connection communication method of any one of claims 1 to 6.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the long-connection communication method of any of claims 1-6.
10. A computer program product comprising a computer program, characterized in that the computer program realizes the long-connection communication method according to any one of claims 1 to 6 when executed by a processor.
CN202110686693.4A 2021-06-21 2021-06-21 Long-connection communication method, system, device, storage medium and program product Active CN113452765B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110686693.4A CN113452765B (en) 2021-06-21 2021-06-21 Long-connection communication method, system, device, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110686693.4A CN113452765B (en) 2021-06-21 2021-06-21 Long-connection communication method, system, device, storage medium and program product

Publications (2)

Publication Number Publication Date
CN113452765A true CN113452765A (en) 2021-09-28
CN113452765B CN113452765B (en) 2023-02-17

Family

ID=77811879

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110686693.4A Active CN113452765B (en) 2021-06-21 2021-06-21 Long-connection communication method, system, device, storage medium and program product

Country Status (1)

Country Link
CN (1) CN113452765B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140258409A1 (en) * 2013-01-30 2014-09-11 Tencent Technology (Shenzhen) Company Limited Method, server and browser for pushing message actively
US20170034174A1 (en) * 2015-07-31 2017-02-02 Gridsystronic Energy Gmbh Method for providing access to a web server
CN107580046A (en) * 2017-08-31 2018-01-12 北京奇虎科技有限公司 Long connection service system and method
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium
CN111083193A (en) * 2019-11-11 2020-04-28 厦门网宿有限公司 Long connection message sending method, server and storage medium
CN111930542A (en) * 2020-08-18 2020-11-13 创新奇智(成都)科技有限公司 Data acquisition method and device, electronic equipment and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140258409A1 (en) * 2013-01-30 2014-09-11 Tencent Technology (Shenzhen) Company Limited Method, server and browser for pushing message actively
US20170034174A1 (en) * 2015-07-31 2017-02-02 Gridsystronic Energy Gmbh Method for providing access to a web server
CN107580046A (en) * 2017-08-31 2018-01-12 北京奇虎科技有限公司 Long connection service system and method
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium
CN111083193A (en) * 2019-11-11 2020-04-28 厦门网宿有限公司 Long connection message sending method, server and storage medium
CN111930542A (en) * 2020-08-18 2020-11-13 创新奇智(成都)科技有限公司 Data acquisition method and device, electronic equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN113452765B (en) 2023-02-17

Similar Documents

Publication Publication Date Title
CN109121468B (en) Access method and device related to network slice
CN109496439B (en) Method and device for establishing unicast connection based on object direct connection
CN109274510B (en) Message processing method, device, client, server and storage medium
US20170063758A1 (en) Method, device, terminal, and router for sending message
CN113783774A (en) Cross-cluster network configuration method and device, communication equipment and storage medium
CN110945883A (en) Paging signaling receiving method and device and paging signaling sending method and device
CN110337825B (en) Service switching method and device
US10798772B2 (en) Method, device and medium for establishing service connection
CN106506808B (en) Method and device for prompting communication message
CN106412855B (en) Information reminding and transmitting method and device
CN106658412B (en) Positioning method and device
CN109245992B (en) Request processing method and device, electronic equipment and storage medium
CN110908814A (en) Message processing method and device, electronic equipment and storage medium
CN114430370B (en) Method, device, equipment and storage medium for determining network slice
CN107295493B (en) Information reporting method, device, terminal and computer readable storage medium
CN113452765B (en) Long-connection communication method, system, device, storage medium and program product
CN106550482B (en) Communication connection establishing method and device and electronic equipment
CN106535147B (en) Communication signal processing method and device
CN113016200B (en) Capability interaction method and device, interaction triggering method and device
CN110710237B (en) Method and device for determining support information
CN110169107B (en) Method and device for realizing wireless network edge calculation
CN115706966A (en) Method and device for connecting network and readable storage medium
CN112769677A (en) Data synchronization method, data synchronization device, electronic equipment, storage medium and program product
CN113163467A (en) Node hop count updating method, device, terminal and storage medium in Mesh network
US10382496B2 (en) Method, apparatus, and computer-readable medium for voice call

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
GR01 Patent grant
GR01 Patent grant