CN111800466A - Method and device for establishing long connection service, electronic equipment and storage medium - Google Patents

Method and device for establishing long connection service, electronic equipment and storage medium Download PDF

Info

Publication number
CN111800466A
CN111800466A CN202010497637.1A CN202010497637A CN111800466A CN 111800466 A CN111800466 A CN 111800466A CN 202010497637 A CN202010497637 A CN 202010497637A CN 111800466 A CN111800466 A CN 111800466A
Authority
CN
China
Prior art keywords
long connection
connection server
terminal
data center
address list
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
CN202010497637.1A
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.)
Zhuomi Private Ltd
Original Assignee
Hong Kong LiveMe Corp 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 Hong Kong LiveMe Corp ltd filed Critical Hong Kong LiveMe Corp ltd
Priority to CN202010497637.1A priority Critical patent/CN111800466A/en
Publication of CN111800466A publication Critical patent/CN111800466A/en
Pending legal-status Critical Current

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/141Setup of application sessions
    • 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/52Network services specially adapted for the location of the user terminal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/69Types of network addresses using geographic information, e.g. room number

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephonic Communication Services (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention discloses a method and a device for establishing a long connection service, electronic equipment and a storage medium, which relate to the technical field of Internet and can enable instant message transmission between users to be more timely. The method comprises the following steps: receiving a long connection server address query request sent by a terminal, wherein the long connection server address query request carries position information of the terminal; the terminal is positioned in the service range of the first data center; generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value; and sending the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list.

Description

Method and device for establishing long connection service, electronic equipment and storage medium
Technical Field
The present invention relates to the field of internet technologies, and in particular, to a method and an apparatus for establishing a long connection service, an electronic device, and a storage medium.
Background
With the rise of applications such as WeChat and live broadcasting, instant messaging becomes an important contact and communication mode among users. In the instant messaging, a user terminal can establish a long connection with a long connection server under a data center, and carry out the instant messaging in specific modes such as single chat, group chat, live broadcast room and the like on the basis of the long connection.
However, as the number of users increases and the distribution range of users becomes wider, the timeliness of instant message transmission between users decreases.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for establishing a long connection service, an electronic device, and a storage medium, which enable instant message transmission between users to be more timely.
In a first aspect, an embodiment of the present invention provides a method for establishing a long connection service, where based on a first data center, the method includes: receiving a long connection server address query request sent by a terminal, wherein the long connection server address query request carries position information of the terminal; the terminal is located in the service range of the first data center; generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value; and sending the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list.
Optionally, the generating, according to the location information of the terminal, a long connection server address list corresponding to the terminal includes: according to the position information of the terminal, acquiring address information of at least two long connection servers, wherein the distance between the first data center and the terminal is smaller than the preset threshold value; and after the address information of the at least two long connection servers is sequenced from near to far from the terminal, the address list of the long connection servers is generated.
Optionally, the long connection server address query request includes a target domain name address; the generating of the long connection server address list corresponding to the terminal according to the location information of the terminal includes: resolving the target domain name address into address information of a plurality of long connection servers; and according to the position information of the terminal, selecting the address information of at least one long connection server with the distance from the terminal being smaller than the preset threshold value from the analyzed address information of the plurality of long connection servers to obtain the address list of the long connection servers.
Optionally, before sending the long connection server address list to the terminal, the method further includes: acquiring address information of at least one long connection server under a second data center by calling a preset program interface, wherein the second data center is different from the first data center; and adding the address information of at least one long connection server under the second data center into the address list.
In a second aspect, an embodiment of the present invention further provides a method for establishing a long connection service, where based on a terminal, the terminal is located in a service range of a first data center, and the method includes: sending a long connection server address query request to the first data center, wherein the long connection server address query request carries the position information of the terminal; receiving a long connection server address list sent by the first data center, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value; and establishing long connection with the corresponding long connection server according to the address list of the long connection server.
Optionally, the address information in the long connection server address list is arranged in a sequence from near to far from the terminal; the establishing of the long connection with the corresponding long connection server according to the long connection server address list comprises: and according to the arrangement sequence of the address information, trying to establish long connection with the long connection server corresponding to the address information in sequence until the long connection is established successfully.
Optionally, the address list of the long connection server further includes address information of the long connection server in the second data center; the establishing of the long connection with the corresponding long connection server according to the long connection server address list comprises: and when the long connection cannot be established with all the long connection servers under the first data center in the address list, trying to establish long connection with the long connection server under the second data center in the address list.
Optionally, after the long connection is established with the corresponding long connection server according to the long connection server address list, the method further includes: storing the address list of the long connection server; if no response is obtained within the preset time after the instant message service request is sent, the long connection with the current long connection server is disconnected, and long connection with other long connection servers in the address list of the long connection server is tried to be established.
In a third aspect, an embodiment of the present invention further provides an apparatus for establishing a long connection service, where based on a first data center, the apparatus includes: the device comprises a request receiving unit, a processing unit and a processing unit, wherein the request receiving unit is used for receiving a long connection server address query request sent by a terminal, and the long connection server address query request carries the position information of the terminal; the terminal is located in the service range of the first data center; the list generating unit is used for generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value; and the list sending unit is used for sending the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list.
Optionally, the list generating unit includes: the acquisition module is used for acquiring address information of at least two long connection servers, the distance between which and the terminal is smaller than the preset threshold value, under the first data center according to the position information of the terminal; and the generating module is used for generating the address list of the long connection servers after the address information of the at least two long connection servers is sequenced from near to far from the terminal.
Optionally, the long connection server address query request includes a target domain name address; the manifest generation unit includes: the resolving module is used for resolving the target domain name address into address information of a plurality of long connection servers; and the selection module is used for selecting the address information of at least one long connection server with the distance from the terminal being less than the preset threshold value from the analyzed address information of the plurality of long connection servers according to the position information of the terminal to obtain the address list of the long connection servers.
Optionally, the apparatus further comprises: an obtaining unit, configured to obtain address information of at least one long connection server in a second data center by calling a preset program interface before sending the address list of the long connection server to the terminal, where the second data center is different from the first data center; and the adding unit is used for adding the address information of at least one long connection server under the second data center into the address list.
In a fourth aspect, an embodiment of the present invention further provides an apparatus for establishing a long connection service, where based on a terminal, the terminal is located in a service range of a first data center, and the apparatus includes: a request sending unit, configured to send a long connection server address query request to the first data center, where the long connection server address query request carries location information of the terminal; the list receiving unit is used for receiving a long connection server address list sent by the first data center, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value; and the connection establishing unit is used for establishing long connection with the corresponding long connection server according to the long connection server address list.
Optionally, the address information in the long connection server address list is arranged in a sequence from near to far from the terminal; the connection establishing unit is specifically configured to try to establish a long connection with a long connection server corresponding to the address information in sequence according to the arrangement order of the address information until the long connection is established successfully.
Optionally, the address list of the long connection server further includes address information of the long connection server in the second data center; the connection establishing unit is further configured to try to establish a long connection with a long connection server in the second data center in the address list when the long connection cannot be established with all long connection servers in the first data center in the address list.
Optionally, the apparatus further comprises: the storage unit is used for storing the long connection server address list after long connection is established with the corresponding long connection server according to the long connection server address list; and the switching unit is used for disconnecting the long connection with the current long connection server and trying to establish long connection with other long connection servers in the address list of the long connection server if no response is obtained within the preset time length after the instant message service request is sent.
In a fifth aspect, an embodiment of the present invention further provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes the program corresponding to the executable program code by reading the executable program code stored in the memory, and is used for executing any one of the methods for establishing the long connection service provided by the embodiment of the invention.
In a sixth aspect, an embodiment of the present invention further provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes the program corresponding to the executable program code by reading the executable program code stored in the memory, and is used for executing any one of the methods for establishing the long connection service provided by the embodiment of the invention.
In a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more processors to implement any one of the methods for establishing a long connection service provided by the embodiments of the present invention.
In an eighth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more processors to implement any one of the methods for establishing a long connection service provided by the embodiments of the present invention.
The method, the device, the electronic equipment and the storage medium for establishing the long connection service provided by the embodiments of the present invention can receive a long connection server address query request sent by a terminal, generate a long connection server address list corresponding to the terminal according to the position information of the terminal carried in the long connection server address query request, where the address list includes address information of at least one long connection server under the first data center, and a distance between the at least one long connection server and the terminal is less than a preset threshold, and then send the long connection server address list to the terminal, so that the terminal establishes a long connection with the corresponding long connection server according to the long connection server address list. Therefore, the address information of one or more connectable long connection servers can be provided for the terminal according to the address query request of the long connection server sent by the terminal, and the distance between the provided long connection servers and the terminal is smaller than the preset threshold value, so that the terminal can establish long connection with the long connection server which is closer to the terminal, and the timeliness of instant message transmission is effectively improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for establishing a long connection service according to an embodiment of the present invention;
fig. 2 is another flowchart of a method for establishing a long connection service according to an embodiment of the present invention;
fig. 3 is a detailed flowchart of a method for establishing a long connection service according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for establishing a long connection service according to an embodiment of the present invention;
fig. 5 is another schematic structural diagram of an apparatus for establishing a long connection service according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to better understand the instant message transmission method provided by the embodiment of the present invention, an application scenario of the instant message transmission method provided by the embodiment of the present invention is briefly introduced first.
In the embodiment of the invention, the users can communicate with each other through instant messages, and the instant messages among different users can be transmitted and forwarded through the data center. The data center may include a series of services for instant message forwarding. In order to smoothly use these services for the instant message transmission and reception service, the terminal may establish a long connection prior to a long connection server under the data center. Based on the long connection service, various types of specific service forms can be established, such as single chat, group chat, live broadcast room and the like.
In a first aspect, an embodiment of the present invention provides a method for establishing a long connection service, which is based on a first data center, and enables instant message transmission between users to be more timely.
As shown in fig. 1, an embodiment of the present invention provides a method for establishing a long connection service, where based on a first data center, the method includes:
s11, receiving a long connection server address query request sent by a terminal, wherein the long connection server address query request carries the position information of the terminal; the terminal is located in the service range of the first data center;
in the embodiment of the invention, before the terminal carries out instant message communication, a long connection is required to be established with the long connection server. Specifically, since the terminal is within the service range of the first data center, the terminal can establish a long connection with one long connection server under the first data center.
In order to enable the terminal to establish a long connection with an appropriate long connection server, in this step, an address query request of the long connection server sent by the terminal may be received, where the query request carries the location information of the terminal. Alternatively, the location information may include various information capable of indicating the location of the terminal, such as GPS (global positioning system) information, IP address information, and the like.
S12, generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
in this step, after receiving the long connection server address query request, the long connection server address list corresponding to the terminal may be generated according to the location information of the terminal carried in the query request. The address list of the long connection server may include address information of one or more long connection servers under the first data center, and a distance between the long connection servers and the terminal is smaller than a preset threshold. Alternatively, the address information in the address list may include IP address information of the long connection server and identification information of a port in the long connection server that provides the long connection service.
That is, in the embodiment of the present invention, the first data center may include a plurality of long connection servers, and the long connection servers may be located in different regions and have different address information. In order to provide a more timely instant messaging service for a terminal, in the embodiment of the present invention, before the terminal establishes a long connection with a long connection server, address information of the long connection server near the terminal may be provided to the terminal in the form of an address list, so that the terminal can preferentially establish the long connection with the long connection server having a shorter distance.
S13, sending the address list of the long connection server to the terminal, so that the terminal establishes a long connection with the corresponding long connection server according to the address list of the long connection server.
After the address list of the long connection server is generated, the address list can be sent to the terminal in the step, so that the terminal establishes long connection with the corresponding long connection server according to the address information in the address list of the long connection server.
The method for establishing the long connection service provided by the embodiment of the invention can receive a long connection server address query request sent by a terminal, generate a long connection server address list corresponding to the terminal according to the position information of the terminal carried in the long connection server address query request, wherein the address list comprises the address information of at least one long connection server under the first data center, and the distance between the at least one long connection server and the terminal is less than a preset threshold value, and then send the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list. Therefore, the address information of one or more connectable long connection servers can be provided for the terminal according to the address query request of the long connection server sent by the terminal, and the distance between the provided long connection servers and the terminal is smaller than the preset threshold value, so that the terminal can establish long connection with the long connection server which is closer to the terminal, and the timeliness of instant message transmission is effectively improved.
Alternatively, in step S12, the long connection server address list may be generated in a variety of ways. For example, in an embodiment of the present invention, generating the long connection server address list corresponding to the terminal according to the location information of the terminal may specifically include:
according to the position information of the terminal, acquiring address information of at least two long connection servers, wherein the distance between the first data center and the terminal is smaller than the preset threshold value;
and after the address information of the at least two long connection servers is sequenced from near to far from the terminal, the address list of the long connection servers is generated.
For example, in an embodiment of the present invention, the location information of the terminal is pos0, and the first data center has 5 long connection servers sv1, sv2, sv3, sv4, sv5, where a distance between sv1, sv4, sv5 and the location pos0 of the terminal is less than a preset threshold (the preset threshold is, for example, 500 km). Then, address information of sv, sv4 and sv5 can be acquired, and if sv1 is away from pos 080 kilometers, sv4 is away from pos 0450 kilometers, and sv5 is away from pos 0240 kilometers, then address information of sv1, sv4 and sv5 can be sorted according to the order of sv1, sv5 and sv4, so as to generate a long connection server address list.
Optionally, the long connection server address query request received in step S11 may be in various request forms, as long as the corresponding APIs (application programming interface) of the terminal and the server are agreed in advance. For example, in an embodiment of the present invention, the query request for the long connection server address may include a target domain name address, for example, a domain name address of an http (hyper text transport protocol) type, and based on this, in step S12, generating the long connection server address list corresponding to the terminal according to the location information of the terminal may specifically include:
resolving the target domain name address into address information of a plurality of long connection servers;
and according to the position information of the terminal, selecting the address information of at least one long connection server with the distance from the terminal being smaller than the preset threshold value from the analyzed address information of the plurality of long connection servers to obtain the address list of the long connection servers.
For example, in one embodiment of the present invention, the received long connection server address query request includes the domain name address http: if/available server inquiry, the address information of a plurality of long connection servers, such as addrl, addr2 and addr3, is analyzed according to the query request, and then the address information of the long connection server, such as addr3, whose distance from the terminal is less than a preset threshold (the preset threshold is 200 kilometers, for example), is selected from the address information, so as to obtain the address list of the long connection server.
That is, in the embodiment of the present invention, DNS (domain name system) intelligent resolution may be performed on the API interface domain name, and according to the area where the user terminal is located, the domain name can be flexibly and accurately reached to the country, province, city, and the like, the data center area to be accessed is divided for the user, so that the user preferentially accesses the relatively long connection server to perform data processing.
Optionally, in the embodiment of the present invention, the address list of the long connection server may include address information of one long connection server or a plurality of long connection servers. In the case that the address information of a plurality of long connection servers is included, the terminal can select one server with the best effect from the servers to establish the long connection, and the terminal can also switch the connection among the plurality of long connection servers.
In the above embodiment, the distances between the long connection servers in the address list and the terminal are all smaller than the preset threshold, but the embodiment of the present invention is not limited thereto. In another embodiment of the present invention, the address list may include all long-connection servers within the service range of the first data center, wherein the recommended priority of the long-connection server whose distance from the terminal is greater than the preset threshold is lower than that of the long-connection server whose distance from the terminal is less than the preset threshold.
Optionally, in an embodiment of the present invention, the recommended priority of the long connection servers in the address list may be gradually decreased according to a sequence from near to far of each long connection server from the terminal. Therefore, on one hand, the terminal can be guaranteed to be preferentially accessed to the long connection server with the shorter distance, and on the other hand, when the long connection server with the shorter distance cannot normally serve, the terminal can be served through other long connection servers in the service range of the first data center.
Further, in the above embodiment, the address information in the address list of the long connection server is in the service range of the first data center, and since the long connection servers are in the same data center, it is easier to respond to the address query request sent by the terminal. However, embodiments of the invention are not limited thereto, and in other embodiments of the invention, the long connection server address list may also include address information of long connection servers within other data center service ranges.
Specifically, in an embodiment of the present invention, before sending the long connection server address list to the terminal in step S13, the method for establishing a long connection service provided in the embodiment of the present invention may further include:
acquiring address information of at least one long connection server under a second data center by calling a preset program interface, wherein the second data center is different from the first data center;
and adding the address information of at least one long connection server under the second data center into the address list.
For example, the long connection server B of the second data center provides a preset program interface, and when the long connection server a of the first data center calls the preset program interface, the address information of the long connection server B of the second data center and/or other long connection servers in the second data center can be obtained. Thus, each data center can flexibly grasp the state information of the long connection servers of other data centers. By performing state synchronization on each data center at regular time, the information of the newly-increased connection server and the failed connection server can be synchronized to other data centers relatively in real time.
Optionally, in the embodiment of the present invention, address information of the long connection server in the second data center may be obtained according to various policies (for example, a random extraction policy or a physical location far and near policy), and the address information may be added to the address list.
Further, in an embodiment of the present invention, the long connection server a may further send the acquired address information of the long connection server in the second data center to a response server of the address query request (for example, a preset domain name resolution server), and when the terminal sends the address query request of the long connection server to the response server, the response server may also provide the address information of the long connection server in the second data center to the terminal.
In a second aspect, an embodiment of the present invention further provides a method for establishing a long connection service, which enables instant message transmission between users to be more timely based on a terminal.
As shown in fig. 2, an embodiment of the present invention provides a method for establishing a long connection service, where, based on a terminal, the terminal is located in a service range of a first data center, the method may include:
s21, sending a long connection server address query request to a first data center, wherein the long connection server address query request carries the position information of the terminal;
in the embodiment of the invention, before the terminal carries out instant message communication, a long connection is required to be established with the long connection server. Specifically, since the terminal is within the service range of the first data center, the terminal can establish a long connection with one long connection server under the first data center.
In order to establish a long connection with a suitable long connection server, in this step, the terminal may first send a long connection server address query request to the first data center (for example, to an address query server under the first data center), where the query request may carry location information of the terminal. Alternatively, the location information may include various information that can indicate the location of the terminal, such as GPS information, IP address information, and the like.
S22, receiving a long connection server address list sent by the first data center, where the long connection server address list includes address information of at least one long connection server in the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
in this step, the first data center may determine, according to the address query request of the long connection server sent by the terminal, address information of one or more long connection servers whose distance from the terminal is smaller than a preset threshold, to form a long connection server address list. The terminal may receive the list of long connection server addresses from the first data center.
And S23, establishing long connection with the corresponding long connection server according to the address list of the long connection server.
In this step, the terminal may establish a long connection with the corresponding long connection server according to the long connection server address in the long connection server address list. Optionally, when only one long connection server address exists in the address list, the terminal may directly establish a long connection with the long connection server, and when a plurality of long connection servers exist in the address list, the terminal may select one long connection server from the long connection servers according to a preset policy to establish the long connection.
According to the method for establishing the long connection service, the terminal can send the address query request of the long connection server to the first data center, receive the address list of the long connection server sent by the first data center, and establish long connection with the corresponding long connection server according to the address list of the long connection server. Because the address query request of the long connection server carries the position information of the terminal, the first data center can determine the address information of each long connection server in the address list of the long connection server according to the position information of the terminal, so that the distance between the long connection server in the address list of the long connection server fed back to the terminal and the terminal is smaller than a preset threshold value, the terminal can establish long connection with the long connection server which is closer to the terminal, and the timeliness of instant message transmission is effectively improved.
Optionally, in an embodiment of the present invention, the address information of the first data center in the address list of the long connection server received in step S22 may be arranged in order from near to far from the terminal; then, in step S23, according to the long connection server address list, establishing a long connection with the corresponding long connection server may specifically include: and according to the arrangement sequence of the address information, trying to establish long connection with the long connection server corresponding to the address information in sequence until the long connection is established successfully. That is, the terminal may preferentially establish a long connection with a long connection server closest to itself, and if the establishment is unsuccessful, attempt to establish a long connection with a long connection server next closest to itself. Therefore, on one hand, the advantage of close range of the server can be fully utilized, the timeliness of instant message transmission is effectively improved, on the other hand, when connection faults occur due to various reasons, connection can be established with other long connection servers, the effectiveness of instant message communication is effectively guaranteed, and the long connection service performance is further improved.
Optionally, in another embodiment of the present invention, the address list of the long connection server received in step S22 may further include address information of the long connection server under the second data center; correspondingly, in step S23, establishing a long connection with the corresponding long connection server according to the long connection server address list may include: and when the long connection cannot be established with all the long connection servers under the first data center in the address list, trying to establish long connection with the long connection server under the second data center in the address list. That is, the terminal may preferentially establish a long connection with the long connection server under the first data center in the address list, and if the establishment is unsuccessful, may attempt to establish a long connection with the long connection server under the second data center in the address list. Therefore, on one hand, the advantage of close range of the long connection server under the data center can be fully utilized, the timeliness of instant message transmission is effectively improved, on the other hand, when connection faults occur due to various reasons, connection can be established with the long connection servers under other data centers, nodes can be switched seamlessly, the service function of the nodes is not sensitive to users, the effectiveness of instant message communication is effectively guaranteed, and the long connection service performance is further improved.
After the terminal establishes long connection with the long connection server, instant message communication can be carried out based on the long connection service provided by the long connection server. However, even if a long connection is established, various instant message requests of the terminal may not be responded to in time due to a long connection server failure or a heavy task. For this reason, in an embodiment of the present invention, after the step S23 establishes the long connection with the corresponding long connection server according to the long connection server address list, the method for establishing the long connection service provided by the embodiment of the present invention may further include:
storing the address list of the long connection server;
if no response is obtained within the preset time after the instant message service request is sent, the long connection with the current long connection server is disconnected, and long connection with other long connection servers in the address list of the long connection server is tried to be established.
In the embodiment of the invention, after the terminal sends the address query request to the first data center once, a long connection server address list can be obtained, the address information of the currently available long connection server is listed on the list, and the terminal can store the address list, so that the address query is not required to be carried out every time long connection is established. However, the state of the available long connection server in the address list may also change, for example, a failure or a heavy task may occur, so that the long connection server is not suitable for being used as the available long connection server, and the long connection server not in the address list may also meet the requirement of providing the long connection service to the terminal in the following.
The following describes a method for establishing a long connection server according to an embodiment of the present invention in detail by using a specific embodiment.
As shown in fig. 3, a method for establishing a long connection server according to an embodiment of the present invention may include:
s301, a long connection server address query request sent by a terminal to an address query server under a first data center, wherein the long connection server address query request carries position information of the terminal; the terminal is located in the service range of a first data center;
s302, the first data center acquires address information of at least two long connection servers, wherein the distance between the first data center and the terminal is smaller than the preset threshold value, according to the position information of the terminal;
s303, after the address information of the at least two long connection servers is sequenced from near to far from the terminal by the first data center, generating a long connection server address list;
s304, the first data center acquires address information of at least one long connection server under a second data center by calling a preset program interface, wherein the second data center is different from the first data center;
s305, the first data center adds the address information of at least one long connection server under the second data center to the address list;
s306, the first data center sends the address list of the long connection server to the terminal;
s307, the terminal tries to establish long connection with the long connection servers corresponding to the address information in sequence according to the sequence of the address information in the address list until the long connection is established successfully, and tries to establish long connection with the long connection servers under the second data center in the address list under the condition that the long connection with all the long connection servers under the first data center in the address list cannot be established;
s308, after the terminal establishes the long connection service, the address list of the long connection server is saved;
s309, in the instant message communication, if no response is obtained within the preset time after the instant message service request is sent, the terminal disconnects the long connection with the current long connection server and tries to establish long connection with other long connection servers in the address list of the long connection server.
In a third aspect, an embodiment of the present invention further provides an apparatus for establishing a long connection service, where the apparatus is disposed in a first data center, and is capable of making instant message transmission between users more timely.
As shown in fig. 4, an embodiment of the present invention provides an apparatus for establishing a long connection service, based on a first data center, including:
a request receiving unit 41, configured to receive a long connection server address query request sent by a terminal, where the long connection server address query request carries location information of the terminal; the terminal is located in the service range of the first data center;
a list generating unit 42, configured to generate a long connection server address list corresponding to the terminal according to the location information of the terminal, where the long connection server address list includes address information of at least one long connection server in the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
a list sending unit 43, configured to send the long connection server address list to the terminal, so that the terminal establishes a long connection with a corresponding long connection server according to the long connection server address list.
The device for establishing the long connection service provided by the embodiment of the invention can receive a long connection server address query request sent by a terminal, generate a long connection server address list corresponding to the terminal according to the position information of the terminal carried in the long connection server address query request, wherein the address list comprises the address information of at least one long connection server under the first data center, and the distance between the at least one long connection server and the terminal is less than a preset threshold value, and then send the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list. Therefore, the address information of one or more connectable long connection servers can be provided for the terminal according to the address query request of the long connection server sent by the terminal, and the distance between the provided long connection servers and the terminal is smaller than the preset threshold value, so that the terminal can establish long connection with the long connection server which is closer to the terminal, and the timeliness of instant message transmission is effectively improved.
Optionally, the list generating unit 42 may include:
the acquisition module is used for acquiring address information of at least two long connection servers, the distance between which and the terminal is smaller than the preset threshold value, under the first data center according to the position information of the terminal;
and the generating module is used for generating the address list of the long connection servers after the address information of the at least two long connection servers is sequenced from near to far from the terminal.
Optionally, the long connection server address query request includes a target domain name address;
the manifest generation unit 42 may include:
the resolving module is used for resolving the target domain name address into address information of a plurality of long connection servers;
and the selection module is used for selecting the address information of at least one long connection server with the distance from the terminal being less than the preset threshold value from the analyzed address information of the plurality of long connection servers according to the position information of the terminal to obtain the address list of the long connection servers.
Optionally, the long connection service establishing apparatus may further include:
an obtaining unit, configured to obtain address information of at least one long connection server in a second data center by calling a preset program interface before sending the address list of the long connection server to the terminal, where the second data center is different from the first data center;
and the adding unit is used for adding the address information of at least one long connection server under the second data center into the address list.
In a fourth aspect, an embodiment of the present invention further provides an apparatus for establishing a long connection service, which is based on a terminal and can enable instant message transmission between users to be more timely.
As shown in fig. 5, an embodiment of the present invention provides an apparatus for establishing a long connection service, which is disposed in a terminal, where the terminal is located in a service range of a first data center, and includes:
a request sending unit 51, configured to send a long connection server address query request to a first data center, where the long connection server address query request carries location information of the terminal;
a list receiving unit 52, configured to receive a long connection server address list sent by the first data center, where the long connection server address list includes address information of at least one long connection server in the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
and the connection establishing unit 53 is configured to establish a long connection with the corresponding long connection server according to the long connection server address list.
According to the device for establishing the long connection service provided by the embodiment of the invention, the terminal can send the address query request of the long connection server to the first data center, receive the address list of the long connection server sent by the first data center and establish long connection with the corresponding long connection server according to the address list of the long connection server. Because the address query request of the long connection server carries the position information of the terminal, the first data center can determine the address information of each long connection server in the address list of the long connection server according to the position information of the terminal, so that the distance between the long connection server in the address list of the long connection server fed back to the terminal and the terminal is smaller than a preset threshold value, the terminal can establish long connection with the long connection server which is closer to the terminal, and the timeliness of instant message transmission is effectively improved.
Optionally, the address information in the long connection server address list is arranged in a sequence from near to far from the terminal; the connection establishing unit 53 is specifically configured to try to establish a long connection with the long connection servers corresponding to the address information in sequence according to the arrangement order of the address information until the long connection is established successfully.
Optionally, the address list of the long connection server further includes address information of the long connection server in the second data center; the connection establishing unit 53 is further configured to, when a long connection cannot be established with all long connection servers in the first data center in the address list, attempt to establish a long connection with a long connection server in the second data center in the address list.
Optionally, the apparatus for establishing a long connection service may further include:
the storage unit is used for storing the long connection server address list after long connection is established with the corresponding long connection server according to the long connection server address list;
and the switching unit is used for disconnecting the long connection with the current long connection server and trying to establish long connection with other long connection servers in the address list of the long connection server if no response is obtained within the preset time length after the instant message service request is sent.
Accordingly, in a fifth aspect, embodiments of the present invention provide an electronic device, which enables instant message transmission between users to be more timely.
As shown in fig. 6, an electronic device provided in an embodiment of the present invention may include: the electronic device comprises a shell 61, a processor 62, a memory 63, a circuit board 64 and a power circuit 65, wherein the circuit board 64 is arranged inside a space enclosed by the shell 61, and the processor 62 and the memory 63 are arranged on the circuit board 64; a power supply circuit 65 for supplying power to each circuit or device of the electronic apparatus; the memory 63 is used to store executable program code; the processor 62 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 63, for executing the method for establishing the long connection service provided by any of the foregoing embodiments.
For the specific execution process of the above steps by the processor 62 and the steps further executed by the processor 62 by running the executable program code, reference may be made to the description of the foregoing embodiments, which are not described herein again.
Accordingly, in a sixth aspect, embodiments of the present invention provide an electronic device, which enables instant message transmission between users to be more timely.
As shown in fig. 7, an electronic device provided in an embodiment of the present invention may include: the device comprises a shell 71, a processor 72, a memory 73, a circuit board 74 and a power circuit 75, wherein the circuit board 74 is arranged inside a space enclosed by the shell 71, and the processor 72 and the memory 73 are arranged on the circuit board 74; a power supply circuit 75 for supplying power to each circuit or device of the electronic apparatus; the memory 73 is used to store executable program code; the processor 72 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 73, for executing the method for establishing the long connection service provided by any of the foregoing embodiments.
For a specific execution process of the above steps by the processor 72 and further steps executed by the processor 72 by running the executable program code, reference may be made to the description of the foregoing embodiments, which are not described herein again.
The above electronic devices exist in a variety of forms, including but not limited to:
(1) a mobile communication device: such devices are characterized by mobile communications capabilities and are primarily targeted at providing voice, data communications. Such terminals include: smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer device: the equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include: PDA, MID, and UMPC devices, etc., such as ipads.
(3) A portable entertainment device: such devices can display and play multimedia content. This type of device comprises: audio, video players (e.g., ipods), handheld game consoles, electronic books, and smart toys and portable car navigation devices.
(4) A server: the device for providing the computing service comprises a processor, a hard disk, a memory, a system bus and the like, and the server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic equipment with data interaction function.
Accordingly, in a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs can be executed by one or more processors to implement any one of the methods for establishing a long connection service provided in the foregoing embodiments, so that corresponding technical effects can also be achieved, and the foregoing has been described in detail, and are not described herein again.
Accordingly, in an eighth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored in the computer-readable storage medium, and the one or more programs can be executed by one or more processors to implement any one of the methods for establishing a long connection service provided in the foregoing embodiments, so that corresponding technical effects can also be achieved, and the foregoing has been described in detail, and are not described again here.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. The term "comprising", without further limitation, means that the element so defined is not excluded from the group consisting of additional identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
For convenience of description, the above devices are described separately in terms of functional division into various units/modules. Of course, the functionality of the units/modules may be implemented in one or more software and/or hardware implementations of the invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method for establishing a long connection service is based on a first data center, and is characterized by comprising the following steps:
receiving a long connection server address query request sent by a terminal, wherein the long connection server address query request carries position information of the terminal; the terminal is located in the service range of the first data center;
generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
and sending the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list.
2. The method according to claim 1, wherein the generating a long connection server address list corresponding to the terminal according to the location information of the terminal comprises:
according to the position information of the terminal, acquiring address information of at least two long connection servers, wherein the distance between the first data center and the terminal is smaller than the preset threshold value;
and after the address information of the at least two long connection servers is sequenced from near to far from the terminal, the address list of the long connection servers is generated.
3. The method of claim 1, wherein the long connection server address query request includes a target domain name address;
the generating of the long connection server address list corresponding to the terminal according to the location information of the terminal includes:
resolving the target domain name address into address information of a plurality of long connection servers;
and according to the position information of the terminal, selecting the address information of at least one long connection server with the distance from the terminal being smaller than the preset threshold value from the analyzed address information of the plurality of long connection servers to obtain the address list of the long connection servers.
4. A method according to any of claims 1 to 3, wherein before sending the list of long connection server addresses to the terminal, the method further comprises:
acquiring address information of at least one long connection server under a second data center by calling a preset program interface, wherein the second data center is different from the first data center;
and adding the address information of at least one long connection server under the second data center into the address list.
5. A method for establishing a long connection service is based on a terminal, wherein the terminal is in a service range of a first data center, and the method comprises the following steps:
sending a long connection server address query request to the first data center, wherein the long connection server address query request carries the position information of the terminal;
receiving a long connection server address list sent by the first data center, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
and establishing long connection with the corresponding long connection server according to the address list of the long connection server.
6. The method according to claim 5, wherein the address information in the long connection server address list is arranged in order from near to far from the terminal;
the establishing of the long connection with the corresponding long connection server according to the long connection server address list comprises: and according to the arrangement sequence of the address information, trying to establish long connection with the long connection server corresponding to the address information in sequence until the long connection is established successfully.
7. The method of claim 5, wherein the long connection server address list further includes address information of a long connection server under the second data center;
the establishing of the long connection with the corresponding long connection server according to the long connection server address list comprises: and when the long connection cannot be established with all the long connection servers under the first data center in the address list, trying to establish long connection with the long connection server under the second data center in the address list.
8. The method according to any one of claims 5 to 7, wherein after establishing a long connection with a corresponding long connection server according to the long connection server address list, the method further comprises:
storing the address list of the long connection server;
if no response is obtained within the preset time after the instant message service request is sent, the long connection with the current long connection server is disconnected, and long connection with other long connection servers in the address list of the long connection server is tried to be established.
9. An apparatus for establishing a long connection service, based on a first data center, includes:
the device comprises a request receiving unit, a processing unit and a processing unit, wherein the request receiving unit is used for receiving a long connection server address query request sent by a terminal, and the long connection server address query request carries the position information of the terminal; the terminal is located in the service range of the first data center;
the list generating unit is used for generating a long connection server address list corresponding to the terminal according to the position information of the terminal, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
and the list sending unit is used for sending the long connection server address list to the terminal so that the terminal establishes long connection with the corresponding long connection server according to the long connection server address list.
10. An apparatus for establishing a long connection service, based on a terminal, the terminal being in a service range of a first data center, the apparatus comprising:
a request sending unit, configured to send a long connection server address query request to the first data center, where the long connection server address query request carries location information of the terminal;
the list receiving unit is used for receiving a long connection server address list sent by the first data center, wherein the long connection server address list comprises address information of at least one long connection server under the first data center; the distance between the at least one long connection server and the terminal is smaller than a preset threshold value;
and the connection establishing unit is used for establishing long connection with the corresponding long connection server according to the long connection server address list.
CN202010497637.1A 2020-06-03 2020-06-03 Method and device for establishing long connection service, electronic equipment and storage medium Pending CN111800466A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010497637.1A CN111800466A (en) 2020-06-03 2020-06-03 Method and device for establishing long connection service, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010497637.1A CN111800466A (en) 2020-06-03 2020-06-03 Method and device for establishing long connection service, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111800466A true CN111800466A (en) 2020-10-20

Family

ID=72806043

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010497637.1A Pending CN111800466A (en) 2020-06-03 2020-06-03 Method and device for establishing long connection service, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111800466A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112653627A (en) * 2020-12-02 2021-04-13 深圳依时货拉拉科技有限公司 Data transmission method, device and system, computer equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105871977A (en) * 2015-11-27 2016-08-17 乐视体育文化产业发展(北京)有限公司 Long connection establishment method and system, and devices
CN107277025A (en) * 2017-06-28 2017-10-20 维沃移动通信有限公司 A kind of Secure Network Assecc method, mobile terminal and computer-readable recording medium
CN107483260A (en) * 2017-08-28 2017-12-15 北京三快在线科技有限公司 Fault handling method and device, electronic equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105871977A (en) * 2015-11-27 2016-08-17 乐视体育文化产业发展(北京)有限公司 Long connection establishment method and system, and devices
CN107277025A (en) * 2017-06-28 2017-10-20 维沃移动通信有限公司 A kind of Secure Network Assecc method, mobile terminal and computer-readable recording medium
CN107483260A (en) * 2017-08-28 2017-12-15 北京三快在线科技有限公司 Fault handling method and device, electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
郭世满,马蕴颖,郭苏宁编著 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112653627A (en) * 2020-12-02 2021-04-13 深圳依时货拉拉科技有限公司 Data transmission method, device and system, computer equipment and computer readable storage medium
CN112653627B (en) * 2020-12-02 2022-11-04 深圳依时货拉拉科技有限公司 Data transmission method, device and system, computer equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN109819285B (en) Live broadcast method and device, electronic equipment and storage medium
CN103747132B (en) The method of display message and terminal
CN110719221B (en) Instant messaging method, device, equipment and storage medium
CN110611723B (en) Scheduling method and device of service resources
US20140328478A1 (en) Method and system for identifying prank call, client, server, and storage medium
CN110650202B (en) Communication interaction method and device and electronic equipment
CN110247739B (en) Message transmission method and device
CN109224435B (en) Online game acceleration method and device, electronic equipment and storage medium
CN110234140B (en) Communication method, device, entity and storage medium
CN109802926B (en) Recommendation model establishing method, live broadcast method and device for content distribution network
US20170171329A1 (en) Video recommendaton method and system, and server
US9402172B2 (en) Message combination method and device
CN108880972B (en) Information processing method, server and terminal
CN103813475A (en) Data transmission method, data acquisition method and electronic device
CN105553831A (en) Message delivery method and system
US10478731B2 (en) Method and apparatus for storing user data
CN103701994A (en) Automatic responding method and automatic responding device
CN111800466A (en) Method and device for establishing long connection service, electronic equipment and storage medium
CN113965402A (en) Configuration method and device of firewall security policy and electronic equipment
CN111314555B (en) Communication method and device of mobile terminal, mobile terminal and storage medium
CN107566215B (en) Wireless network cutout detection method, device, storage medium and mobile terminal
CN111726280A (en) Instant message transmission method and device, electronic equipment and storage medium
CN109981796B (en) Connection method and device
CN106648656B (en) Message deleting method and device and electronic equipment
CN111726281A (en) Instant message transmission method and device, electronic equipment and storage medium

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210602

Address after: 25, 5th floor, shuangjingfang office building, 3 frisha street, 189352, Singapore

Applicant after: Zhuomi Private Ltd.

Address before: Room 1101, Santai Commercial Building, 139 Connaught Road, Hong Kong, China

Applicant before: HONG KONG LIVE.ME Corp.,Ltd.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201020