WO2017041381A1 - 多业务共享长连接方法、系统及其装置、终端 - Google Patents
多业务共享长连接方法、系统及其装置、终端 Download PDFInfo
- Publication number
- WO2017041381A1 WO2017041381A1 PCT/CN2015/097955 CN2015097955W WO2017041381A1 WO 2017041381 A1 WO2017041381 A1 WO 2017041381A1 CN 2015097955 W CN2015097955 W CN 2015097955W WO 2017041381 A1 WO2017041381 A1 WO 2017041381A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- heartbeat time
- long
- server
- heartbeat
- service
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/04—Processing captured monitoring data, e.g. for logfile generation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/10—Mapping addresses of different types
- H04L61/106—Mapping addresses of different types across networks, e.g. mapping telephone numbers to data network addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/55—Push-based network services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
Definitions
- the present invention relates to the field of communications technologies, and in particular, to a multi-service shared long connection system, an apparatus, and a terminal.
- IP Internet Protocol
- Most terminal devices such as mobile phones, computers, and smart TVs, use intranet IP under the network operator gateway. For example, they all use IPV4 and do not have independent public IP.
- network operators will recycle addresses that are not used for a long time, and such recycling will not be notified. Therefore, under normal circumstances, the client existing in the terminal and the server existing in the network operator cannot know that the connection established between them has been reclaimed if no communication attempt is made.
- the client in various terminals sends a request for obtaining information to the server of the network operator unilaterally, which can no longer meet the requirement that the app of the terminal can obtain information in time.
- a news app on a terminal when a major news occurs, the server can promptly push the message to the terminal to remind the user, and then the server of the network operator can immediately notify the client in the terminal, instead of It is limited to the client unilaterally requesting from the server.
- a long connection In order to enable the client and server to notify each other in the current situation of the network, a long connection needs to be established.
- one service uses a long connection, so that the long connection is not used efficiently, and the long connection is mostly idle. Because the heartbeat time cannot be aligned on the terminal, the CPU is often woken up and the power consumption is severe. And it is necessary to periodically send a heartbeat to maintain the survival of a long connection. Due to the variety of terminals, the network environment will be different. Some networks are good. It is possible to send a heartbeat in an hour. Some networks may take a minute to get a heartbeat. If you unify a heartbeat time, you must only take the lowest value, otherwise many can't live.
- the main purpose of the present invention is to provide a multi-service shared long connection system, and a device and a terminal thereof, which are designed to realize a long connection channel for multi-service sharing and improve utilization of long connections.
- the present invention provides a multi-service shared long connection method, including:
- the long-connected client establishes a channel for transmitting data to the server of the long connection, and acquires the heartbeat time to maintain the survival of the long connection;
- the long-connected server configures a unique service ID for each service according to the application request of each service, and sends the service ID to the long-connected client;
- the long-connected client transmits the received service ID to the corresponding service client for reporting to the corresponding service server;
- the long-connected server After receiving the service information pushed by the service server, the long-connected server sends the service information to the long-connected client through the channel according to the service ID;
- the long-connected client pushes the business information to the business client according to the service ID.
- the long-connected server configures a unique service ID for each service according to an application request of each service and sends the message to the long-connected client, including:
- the long-connected server receives the service label application request sent by each service, and returns a service identifier to the service client according to the service label application request;
- the long-connected client receives the service identifier sent by the service client, and establishes a unique feature value for identifying the terminal according to the attribute information of the terminal where the long-connected client is located, and transmits the service identifier and the feature value to the same Describe the server of the long connection;
- the long-connected server generates a service ID corresponding to each service according to the service indication and the feature value, and sends the service ID to the persistently connected client.
- the long-connected client establishes a channel for transmitting data to the server of the long connection, and acquiring the heartbeat time to maintain the survival of the long connection includes:
- the initial heartbeat time calculates a second heartbeat time, and continues to send the second heartbeat time to the server of the long connection until the feedback of the server of the long connection is not received;
- the time until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- the heartbeat time is calculated according to the following formula:
- the initial heartbeat increase step is calculated according to the following formula:
- B 0 (f(n)-f(n-1))/2; where n ⁇ 1, B 0 represents the initial heartbeat increase step size, f(n) represents the second heartbeat time, f(n-1) Indicates the previous heartbeat time of the second heartbeat time;
- B n (B n-1 )/2; wherein n ⁇ 1, B n represents a new heartbeat increase step size, and B n-1 represents a previous heartbeat increase step size of the new heartbeat increase step size;
- the first heartbeat time is calculated according to the initial heartbeat time, and the first heartbeat time is transmitted to the server of the long connection, and when the feedback of the server of the long connection is received, the first The heartbeat time calculates the second heartbeat time as the new initial heartbeat time, and continues to send the second heartbeat time to the server of the long connection until the feedback of the server that does not receive the long connection includes:
- the present invention further provides a multi-service shared long connection system, where the multi-service shared long connection system includes a long-connected client and a long-connected server, wherein
- a long-connected client that establishes a channel for transmitting data to a server with a long connection, and Get the heartbeat time to maintain the survival of long connections;
- the long-connected server is configured to configure a unique service ID for each service according to the application request of each service, and send the service ID to the long-connected client;
- a long-connected client configured to transmit the received service ID to a corresponding service client for reporting to the corresponding service server;
- the long-connected server is configured to send the service information to the long-connected client through the channel according to the service ID after receiving the service information pushed by the service server;
- a long-connected client that pushes business information to the business client based on the business ID.
- the long-connected server is further configured to receive a service indication application request sent by each service, and return a service indication to the service client according to the service indication application request;
- the long-connected client is further configured to receive a service identifier sent by the service client, and establish a unique feature value for identifying the terminal according to the attribute information of the terminal where the long-connected client is located, and use the service identifier and the feature value. Delivered together to the server of the long connection;
- the long-connected server is further configured to generate a service ID corresponding to each service according to the service indication and the feature value, and send the service ID to the persistently connected client.
- the present invention further provides a method for acquiring a long-connected heartbeat time, including:
- the initial heartbeat time calculates a second heartbeat time, and continues to send the second heartbeat time to the server of the long connection until the feedback of the server of the long connection is not received;
- the time calculation calculates the fourth heartbeat time until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is used as the survival heartbeat time for maintaining the long connection.
- the heartbeat time is calculated according to the following formula:
- the initial heartbeat increase step is calculated according to the following formula:
- B 0 (f(n)-f(n-1))/2; where n ⁇ 1, B 0 represents the initial heartbeat increase step size, f(n) represents the second heartbeat time, f(n-1) Indicates the previous heartbeat time of the second heartbeat time;
- B n (B n-1 )/2; wherein n ⁇ 1, B n represents a new heartbeat increase step size, and B n-1 represents a previous heartbeat increase step size of the new heartbeat increase step size;
- the calculating a first heartbeat time according to the initial heartbeat time, and transmitting the first heartbeat time to the server of the long connection, when receiving the feedback of the server of the long connection The first heartbeat time calculates the second heartbeat time as the new initial heartbeat time, and continues to send the second heartbeat time to the server of the long connection, until the feedback of the server that does not receive the long connection includes:
- the present invention further provides a long-connected heartbeat time acquiring device, including:
- An initial heartbeat time acquisition module configured to determine an initial heartbeat time according to a current network environment
- a second heartbeat time acquisition module configured to calculate a first heartbeat time according to the initial heartbeat time, and transmit the first heartbeat time to the server of the long connection, and receive the long-connected service
- the second heartbeat time is calculated by using the first heartbeat time as the new initial heartbeat time, and the second heartbeat time is continuously sent to the server of the long connection until the feedback of the server of the long connection is not received;
- a transmitting module configured to: when the feedback of the server of the long connection is not received, transmit the initial heartbeat time to the server of the long connection, where the server that receives the long connection is for an initial heartbeat time Sending, the previous heartbeat time of the second heartbeat time is transmitted to the server of the long connection;
- An initial heartbeat increase step size obtaining module configured to calculate an initial heartbeat increase step size according to the second heartbeat time and the previous heartbeat time after receiving the feedback of the long-connected server;
- a fourth heartbeat time acquisition module configured to calculate a third heartbeat time according to the initial heartbeat increase step size and the second heartbeat time, calculate a new heartbeat increase step size according to the initial heartbeat increase step size, and increase the step size according to the new heartbeat
- the third heartbeat time is calculated to obtain the fourth heartbeat time until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- the heartbeat time is calculated according to the following formula:
- the initial heartbeat increase step is calculated according to the following formula:
- B 0 (f(n)-f(n-1))/2; where n ⁇ 1, B 0 represents the initial heartbeat increase step size, f(n) represents the second heartbeat time, f(n-1) Indicates the previous heartbeat time of the second heartbeat time;
- B n (B n-1 )/2; wherein n ⁇ 1, B n represents a new heartbeat increase step size, and B n-1 represents a previous heartbeat increase step size of the new heartbeat increase step size;
- the second heartbeat time obtaining module is further configured to: when the first heartbeat time or the second heartbeat time is transmitted to the server of the long connection, the preset number of transmissions does not satisfy the server that receives the long connection The preset number of times of feedback determines the feedback of the server that has not received the long connection.
- the present invention also provides a terminal including the long-connected heartbeat time acquiring means of the above structure.
- the long-connected server configures a unique service ID for each service according to the application request of each service, and sends the service ID to the long-connected client.
- the long-connected client transmits the received service ID to the corresponding service client for reporting to the corresponding service server.
- the long-connected server After receiving the service information pushed by the service server, the long-connected server sends the service information to the long-connected client through the channel according to the service ID, and the long-connected client pushes the service information to the service client according to the service ID. .
- a long connection channel is shared by multiple services, and the utilization of long connections is improved.
- FIG. 1 is a schematic flowchart of an embodiment of a multi-service shared long connection method according to the present invention
- FIG. 2 is a schematic diagram of a refinement process in which a long-connected server configures a unique service ID for each service and sends it to a long-connected client according to an application request of each service in the multi-service shared long connection method of the present invention
- FIG. 3 is a schematic diagram of a refinement process for a long-connected client to establish a channel for transmitting data to a long-connected server, and obtaining a heartbeat time to maintain a long connection, in the multi-service shared long connection method of the present invention
- FIG. 4 is a schematic flowchart of an embodiment of a method for acquiring a heartbeat time of a long connection according to the present invention
- FIG. 5 is a schematic diagram of functional modules of an embodiment of a long-connected heartbeat time acquiring apparatus according to the present invention.
- the multi-service shared long connection method of this embodiment includes:
- Step S10 The long-connected client establishes a channel for transmitting data to the server of the long connection, and acquires a heartbeat time to maintain the survival of the long connection;
- a stable and adaptive long connection can be created from the system level of the terminal.
- the long-connected client in the terminal needs to establish a channel for transmitting data according to the network protocol with the server of the long connection, and the type of the terminal can be set according to actual needs, for example, a mobile phone, a computer, a smart TV, and the like.
- the client that is long-connected first establishes a channel for transmitting data with the server that is connected to the long connection, for example, establishing a TCPSocket.
- the long-connected client sends an online command to the long-connected server according to the message protocol, and waits for the server that receives the long connection to issue the command.
- the message protocol may be a pre-set network protocol for transmitting data. For example, a client with a long connection sends a "1" as an online command, a "2" is an offline command, and a command can return a "3" for a long-connected server. "" indicates that the client has received a long connection.
- the long-connected client When the long-connected client receives a reply from the server with a long connection, it indicates that the long-connected server has received the online command sent by the long-connected client, and the message is parsed according to the message protocol to obtain the transmitted message content. And according to the content prompts for corresponding processing. Then the long-connected client obtains the heartbeat time, transmits the obtained current heartbeat time to the long-connected server, and waits for the server to return the heartbeat time. After receiving the message returned by the server with a long connection, the client that repeats the long connection resolves the message according to the message protocol and obtains the current heartbeat time and transmits it to the server of the long connection until the optimal heartbeat time is obtained.
- the heartbeat time maintains the survival of long connections, ie, maintains the stability of the channel. This long connection is established for sharing by multiple services.
- Step S20 The long-connected server configures a unique service ID for each service according to the application request of each service, and sends the service ID to the persistently connected client.
- each service requests the long-connected server to obtain the respective number, that is, each service is connected to the long-connected server.
- the long-connected server configures a unique service ID for each service after receiving the request, and sends the configured service ID to the long-connected client for the long-connected client to conduct the service.
- the ID is delivered to the business client.
- Step S30 The long-connected client transmits the received service ID to the corresponding service customer.
- the client is for reporting to the corresponding service server;
- the long-connected client After receiving the service IDs sent by the server connected by the long connection, the long-connected client transmits each service ID to the corresponding service client. After receiving the service ID, each service client reports the service ID to its corresponding service server.
- Step S40 After receiving the service information pushed by the service server, the long-connected server sends the service information to the long-connected client through the channel according to the service ID.
- the service information to be pushed is sent to the server of the long connection together with the service ID.
- the long-connected server finds the terminal where the long-connected client is located according to the service ID, and establishes the long-connected server and the long-connected client through the above-mentioned established server. A channel for data transmission, which sends service information to a long-connected client.
- Step S50 The long-connected client pushes the service information to the service client according to the service ID.
- the long-connected client After receiving the service ID and service information sent by the server connected by the long connection, the long-connected client finds the corresponding service according to the service ID, and pushes the service information to the service client.
- the long-connected client on the smart TV creates a channel that uses the network protocol to transfer data between the long-connected server, that is, creates a long connection.
- the long-connected client can be named com.tianci.push.
- the three services of the smart TV upgrade service, the video push service, and the module update service respectively apply for a separate service mark to the established long-connected server.
- the upgrade service, the video push service, and the module update service use android broadcast to send the package name (ie, the key information of the service) and the corresponding service identifier to com.tianci.push.
- the com.tianci.push After receiving the self-package name and the corresponding service identifier transmitted by the three services, the com.tianci.push associates the three service identifiers with the corresponding package names in the database.
- Com.tianci.push constructs a feature value of a long connection corresponding to the smart TV according to the information of the smart TV, and the feature value is unique, and the feature value may include a version number, a physical address, and the like of the smart TV.
- Com.tianci.push sends the eigenvalue and the three service identifiers to the long-connected server through the long-connected data transmission channel, and the long-connected server generates the trait according to the eigenvalue and the three service labels.
- the service ID corresponding to each service and return the service ID and the corresponding service identifier to com.tianci.push.
- Com.tianci.push updates the database according to the service indications of the three services, that is, stores the service identifiers of the three services, their respective service IDs, and their respective package names in the database. At the same time, find the respective package names of the three services, and send the three service IDs to the corresponding services.
- the video and video push service reports the service ID to the server of the video push service.
- the server of the video push service sends the service ID and the video push service information to the long-connected server.
- the long-connected server finds the smart TV device according to the service ID, and sends the service ID and the video push service information to the com.tianic.push located on the smart TV.
- com.tianci.push finds the package name of the video push service, and assigns the video push service information to the client of the video push service.
- the client of the video push service parses and processes the received information according to its own protocol.
- the long-connected server configures a unique service ID for each service according to the application request of each service, and sends the service ID to the long-connected client.
- the long-connected client transmits the received service ID to the corresponding service client for reporting to the corresponding service server.
- the long-connected server After receiving the service information pushed by the service server, the long-connected server sends the service information to the long-connected client through the channel according to the service ID, and the long-connected client pushes the service information to the service client according to the service ID. .
- a long connection channel is shared by multiple services, and the utilization of long connections is improved.
- the foregoing step S20 may include:
- Step S21 The server that is connected to the long end receives the service label application request sent by each service, and returns a service identifier to the service client according to the service label application request;
- the long-connected server configures a unique service ID for each service according to the application request of each service. Specifically, each service first applies for a service identifier to the long-connected server. The long-connected server returns a service identifier to the corresponding service client according to the service label application request sent by each service. Then, each service client transmits the respective service identifier to the long-connected client on the terminal. Understandably, the multi-service is two or More than two services, of course, if the single connection uses the long connection, it is not necessary to apply for a service indication to the long-connected server.
- Step S22 The long-connected client receives the service identifier sent by the service client, and establishes a unique feature value for identifying the terminal according to the attribute information of the terminal where the long-connected client is located, and the service identifier and the feature value are together. Transmitting to the server of the long connection;
- the long-connected client After receiving the service identifier, the long-connected client associates each service identifier with the key information of the corresponding service as a pair of key values in the database, so as to obtain the key information of the service according to the service indication.
- the key information of the business can include the name of the business.
- the attribute information of the terminal is obtained as the unique feature value of the terminal according to the terminal where the client is connected, for example, the feature value may include the physical address, version number, etc. of the terminal where the connected client is located. .
- the characteristic values of the service identifiers and the long connections are transmitted together to the server of the long connection, so that the long-connected server can generate the service ID corresponding to each service according to the characteristic values of the service identifiers and the long connections.
- Step S23 The long-connected server generates a service ID corresponding to each service according to the service indication and the feature value, and sends the service ID to the persistently connected client.
- the server that is connected to the long-term connection After receiving the characteristic values of the service identifiers and the long connections, the server that is connected to the long-term connection checks whether the service labels are correct according to the respective service identifiers applied by the long-connected server to each service, that is, whether the service is forward-connected. The service sign of the server application. If it is correct, the long-connected server generates a unique service ID corresponding to each service according to the feature value of the long connection and each service identifier, and returns each service ID and corresponding service identifier to the long-connected client. After receiving the service IDs and the corresponding service identifiers, the long-connected client associates the service IDs of each service with the service IDs, and stores the service IDs, service identifiers, and business key information of each service in the database. The database for updating the key information of each of the indications and the corresponding service is updated.
- the foregoing step S10 may include:
- Step S11 Determine an initial heartbeat time according to a current network environment.
- the long-connected client After the long-connected client establishes a connection with the long-connected server, the long-connected client sends its own related information to the long-connected server, and the long-connected server identifies the long-connected client.
- the terminal in order to complete the process of initializing the server on the long connection.
- the long-connected client Since the initial heartbeat time is related to the network environment, the long-connected client initializes the initial heartbeat time according to the current network environment in which the terminal is located by detecting the current network environment.
- the default initial value can be set to 10 to 50 seconds, or can be flexibly set according to the specific situation.
- Step S12 Calculate a first heartbeat time according to the initial heartbeat time, and transmit the first heartbeat time to the server of the long connection, and receive the feedback of the server that is connected to the first heartbeat time. Calculating the second heartbeat time as the new initial heartbeat time, and continuing to send the second heartbeat time to the server of the long connection until the feedback of the server of the long connection is not received;
- the long-connected client obtains the first heartbeat time
- the first heartbeat time is transmitted to the long-connected server.
- the step increment is repeated to calculate the second heartbeat time according to the formula.
- the obtained second heartbeat time is continuously sent to the server of the long connection until the feedback of the server of the long connection is not received, and the calculation of the second heartbeat time by the above formula is stopped.
- the feedback of the server that is connected to the long connection may be the heartbeat time sent by the client that returns the long connection, or may return the specified information according to a preset protocol.
- the second heartbeat time is repeatedly calculated by the above formula, so that in the process of finding the optimal heartbeat time, when the heartbeat time increases rapidly, the critical value of the heartbeat time is found as few times as possible.
- the long-connected client may transmit the first heartbeat time or the second heartbeat time to the server of the long connection multiple times.
- the preset number of transmissions of transmitting the first heartbeat time or the second heartbeat time to the server of the long connection does not satisfy the preset number of times of receiving the server feedback of the long connection, it is determined that the feedback of the server of the long connection is not received.
- the preset number of transmissions and the preset number of times can be flexibly set according to specific conditions. For example, a long-connected client transmits the first heartbeat time 3 times to a long-connected server. If the server receives a long-connected server feedback 3 times, the long-connected client will be the first. When a heartbeat time is sent to the server of the long connection, the feedback of the server of the long connection can be successfully received.
- Step S13 When the feedback of the long-connected server is not received, the initial heartbeat time is Transmitting to the server of the long connection, when receiving the feedback of the server of the long connection for the initial heartbeat time, transmitting the previous heartbeat time of the second heartbeat time to the server of the long connection;
- the initial heartbeat time is used to try, that is, the long-connected client transmits the initial heartbeat time to the long-connected server to detect Whether the long-connected client will receive the long-connected server returns the initial heartbeat time.
- the long-connected client may transmit the initial heartbeat time to the long-connected server multiple times, and perform corresponding processing according to whether the preset number of feedbacks of the server that receives the long-connection is received on time. For example, a client with a long connection can transmit the initial heartbeat time 5 times to the server of the long connection. When the feedback of the server that receives the long connection on time is 5 or 4 times, the server that successfully receives the long connection is successfully received. Feedback, otherwise it fails.
- the process proceeds to step 11 to re-initialize the heartbeat time.
- the previous heartbeat time of the second heartbeat time is used to try, that is, the previous heartbeat time of the second heartbeat time is transmitted to the long-connected service. end.
- the second heartbeat time is the last heartbeat time that is sent when the server that receives the long connection does not receive feedback for the second heartbeat time.
- the number of times the previous heartbeat time is transmitted can be flexibly set according to the specific situation, and corresponding processing is performed according to whether the preset number of feedbacks of the server that receives the long connection on time is satisfied.
- Step S14 After receiving the feedback of the server that is connected to the long connection, calculate an initial heartbeat increase step according to the second heartbeat time and the previous heartbeat time;
- the process proceeds to step 11 to re-initialize the heartbeat time.
- B 0 represents an initial heart rate increase in step length
- f (n) represents a second heartbeat time
- f (n-1) represents a second heartbeat time before the time of a heartbeat.
- Step S15 Calculate a third heartbeat time according to the initial heartbeat increase step size and the second heartbeat time, calculate a new heartbeat increase step size according to the initial heartbeat increase step size, and calculate according to the new heartbeat increase step size and the third heartbeat time.
- the fourth heartbeat time is until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step is zero, and the fourth heartbeat time at this time is used as the long-term connection. Survival heartbeat time.
- B n represents a new heartbeat increase step size
- B n-1 represents a previous heartbeat increase step size of the new heartbeat increase step.
- the optimal value can be quickly found.
- the long-connected client sends the obtained third heartbeat time to the server of the long connection, and when receiving the feedback of the server with the long connection, increments n by 1 step, and calculates the fourth heartbeat according to the formula. time.
- the process proceeds to step S13, and the initial heartbeat time is retransmitted to the server of the long connection to try.
- the long-connected client then sends the obtained fourth heartbeat time to the long-connected server, and when receiving the feedback of the long-connected server for the fourth heartbeat time, increments n to continue calculating the fourth heartbeat time until it is obtained.
- the fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- the multi-service shared long connection system includes a long-connected client and a long-connected server.
- a long-connected client that establishes a channel for transmitting data to a long-connected server and acquires heartbeat time to maintain the survival of a long connection
- a stable and adaptive long connection can be created from the system level of the terminal.
- the long-connected client in the terminal needs to establish a channel for transmitting data according to the network protocol with the server of the long connection, and the type of the terminal can be set according to actual needs, for example, a mobile phone, a computer, a smart TV, and the like.
- the client that is long-connected first establishes a channel for transmitting data with the server that is connected to the long connection, for example, establishing a TCPSocket.
- the long-connected client sends an online command to the long-connected server according to the message protocol, and waits for the server that receives the long connection to issue the command.
- the message protocol may be a pre-set network protocol for transmitting data. For example, a client with a long connection sends a "1" as an online command, a "2" is an offline command, and a command can return a "3" for a long-connected server. "" indicates that the client has received a long connection.
- a long-connected client When a long-connected client receives a reply from a long-connected server, it indicates that the long-connected server has received a long connection.
- the online command sent by the client at this time, the message will be parsed according to the message protocol to obtain the content of the transmitted message, and corresponding processing is performed according to the content prompt.
- the long-connected client obtains the heartbeat time, transmits the obtained current heartbeat time to the long-connected server, and waits for the server to return the heartbeat time.
- the client that repeats the long connection resolves the message according to the message protocol and obtains the current heartbeat time and transmits it to the server of the long connection until the optimal heartbeat time is obtained.
- the heartbeat time maintains the survival of long connections, ie, maintains the stability of the channel. This long connection is established for sharing by multiple services.
- the long-connected server is configured to configure a unique service ID for each service according to the application request of each service, and send the service ID to the long-connected client;
- each service requests the long-connected server to obtain the respective number, that is, each service is connected to the long-connected server.
- the long-connected server configures a unique service ID for each service after receiving the request, and sends the configured service ID to the long-connected client for the long-connected client to conduct the service.
- the ID is delivered to the business client.
- a long-connected client configured to transmit the received service ID to a corresponding service client for reporting to the corresponding service server;
- the long-connected client After receiving the service IDs sent by the server connected by the long connection, the long-connected client transmits each service ID to the corresponding service client. After receiving the service ID, each service client reports the service ID to its corresponding service server.
- the long-connected server is configured to send the service information to the long-connected client through the channel according to the service ID after receiving the service information pushed by the service server;
- the service information to be pushed is sent to the server of the long connection together with the service ID.
- the long-connected server finds the terminal where the long-connected client is located according to the service ID, and establishes the long-connected server and the long-connected client through the above-mentioned established server. A channel for data transmission, which sends service information to a long-connected client.
- a long-connected client that pushes business information to the business client based on the business ID.
- the long-connected client After receiving the service ID and service information sent by the server connected by the long connection, the long-connected client finds the corresponding service according to the service ID, and pushes the service information to the service client.
- the long-connected client on the smart TV creates a channel that uses the network protocol to transfer data between the long-connected server, that is, creates a long connection.
- the long-connected client can be named com.tianci.push.
- the three services of the smart TV upgrade service, the video push service, and the module update service respectively apply for a separate service mark to the established long-connected server.
- the upgrade service, the video push service, and the module update service use android broadcast to send the package name (ie, the key information of the service) and the corresponding service identifier to com.tianci.push.
- the com.tianci.push After receiving the self-package name and the corresponding service identifier transmitted by the three services, the com.tianci.push associates the three service identifiers with the corresponding package names in the database.
- Com.tianci.push constructs a feature value of a long connection corresponding to the smart TV according to the information of the smart TV, and the feature value is unique, and the feature value may include a version number, a physical address, and the like of the smart TV.
- Com.tianci.push sends the feature value and the three service identifiers to the long-connected server through the long-connected data transmission channel, and the long-connected server generates the service corresponding to each service according to the feature value and the three service indicators. ID, and return the business ID and corresponding business identifier to com.tianci.push.
- Com.tianci.push updates the database according to the service indications of the three services, that is, stores the service identifiers of the three services, their respective service IDs, and their respective package names in the database. At the same time, find the respective package names of the three services, and send the three service IDs to the corresponding services.
- the video and video push service reports the service ID to the server of the video push service.
- the server of the video push service sends the service ID and the video push service information to the long-connected server.
- the long-connected server finds the smart TV device according to the service ID, and sends the service ID and the video push service information to the com.tianic.push located on the smart TV.
- com.tianci.push finds the package name of the video push service, and assigns the video push service information to the client of the video push service.
- the client of the video push service parses and processes the received information according to its own protocol.
- the long-connected server configures a unique service ID for each service according to the application request of each service, and the service is The ID is sent to the client of the long connection.
- the long-connected client transmits the received service ID to the corresponding service client for reporting to the corresponding service server.
- the long-connected server After receiving the service information pushed by the service server, the long-connected server sends the service information to the long-connected client through the channel according to the service ID, and the long-connected client pushes the service information to the service client according to the service ID. .
- a long connection channel is shared by multiple services, and the utilization of long connections is improved.
- the long-connected server is further configured to receive a service label application request sent by each service, and return a service identifier to the service client according to the service label application request;
- the long-connected server configures a unique service ID for each service according to the application request of each service. Specifically, each service first applies for a service identifier to the long-connected server. The long-connected server returns a service identifier to the corresponding service client according to the service label application request sent by each service. Then, each service client transmits the respective service identifier to the long-connected client on the terminal. It can be understood that the multi-service is two or more services. Of course, if the single service uses the long connection, it is not required to apply for the service indication to the long-connected server.
- the long-connected client is further configured to receive a service identifier sent by the service client, and establish a unique feature value for identifying the terminal according to the attribute information of the terminal where the long-connected client is located, and use the service identifier and the feature value. Delivered together to the server of the long connection;
- the long-connected client After receiving the service identifier, the long-connected client associates each service identifier with the key information of the corresponding service as a pair of key values in the database, so as to obtain the key information of the service according to the service indication.
- the key information of the business can include the name of the business.
- the attribute information of the terminal is obtained as the unique feature value of the terminal according to the terminal where the client is connected, for example, the feature value may include the physical address, version number, etc. of the terminal where the connected client is located. .
- the characteristic values of the service identifiers and the long connections are transmitted together to the server of the long connection, so that the long-connected server can generate the service ID corresponding to each service according to the characteristic values of the service identifiers and the long connections.
- the long-connected server is further configured to generate a service ID corresponding to each service according to the service indication and the feature value, and send the service ID to the persistently connected client.
- the long-connected server After the long-connected server receives the characteristic values of each service indicator and long connection, according to each industry The respective service identifiers of the long-connected server applications are checked, and whether the service identifiers are correct, that is, whether the service identifiers previously applied to the long-connected server are applied. If it is correct, the long-connected server generates a unique service ID corresponding to each service according to the feature value of the long connection and each service identifier, and returns each service ID and corresponding service identifier to the long-connected client. After receiving the service IDs and the corresponding service identifiers, the long-connected client associates the service IDs of each service with the service IDs, and stores the service IDs, service identifiers, and business key information of each service in the database. The database for updating the key information of each of the indications and the corresponding service is updated.
- the long-connected heartbeat time acquisition method of this embodiment includes:
- Step S1 determining an initial heartbeat time according to a current network environment
- the long-connected client After the long-connected client establishes a connection with the long-connected server, the long-connected client sends its own related information to the long-connected server, and the long-connected server identifies the long-connected client to complete the long The process of connecting the server to the line initialization.
- the long-connected client Since the initial heartbeat time is related to the network environment, the long-connected client initializes the initial heartbeat time according to the current network environment in which the terminal is located by detecting the current network environment.
- the default initial value can be set to 10 to 50 seconds, or can be flexibly set according to the specific situation.
- Step S2 Calculate a first heartbeat time according to the initial heartbeat time, and transmit the first heartbeat time to the server of the long connection, and receive the feedback of the server that is connected to the first heartbeat time. Calculating the second heartbeat time as the new initial heartbeat time, and continuing to send the second heartbeat time to the server of the long connection until the feedback of the server of the long connection is not received;
- the long-connected client obtains the first heartbeat time
- the first heartbeat time is transmitted to the long-connected server.
- the server When receiving the feedback of the server with the long connection, it indicates that the first heartbeat time is successful for maintaining the survival of the long connection, and then calculating the second heartbeat time with the first heartbeat time as the new initial heartbeat time, that is, n is 1
- the step increment is repeated to calculate the second heartbeat time according to the formula. Will get the second heartbeat time to continue
- the server is sent to the long-connected server until the feedback of the server with the long connection is not received, and the second heartbeat time is stopped by the above formula.
- the feedback of the server that is connected to the long connection may be the heartbeat time sent by the client that returns the long connection, or may return the specified information according to a preset protocol.
- the second heartbeat time is repeatedly calculated by the above formula, so that in the process of finding the optimal heartbeat time, when the heartbeat time increases rapidly, the critical value of the heartbeat time is found as few times as possible.
- the long-connected client may transmit the first heartbeat time or the second heartbeat time to the server of the long connection multiple times.
- the preset number of transmissions of transmitting the first heartbeat time or the second heartbeat time to the server of the long connection does not satisfy the preset number of times of receiving the server feedback of the long connection, it is determined that the feedback of the server of the long connection is not received.
- the preset number of transmissions and the preset number of times can be flexibly set according to specific conditions. For example, a long-connected client transmits the first heartbeat time 3 times to a long-connected server. If the server receives a long-connected server feedback 3 times, the long-connected client will be the first. When a heartbeat time is sent to the server of the long connection, the feedback of the server of the long connection can be successfully received.
- Step S3 When the feedback of the long-connected server is not received, the initial heartbeat time is transmitted to the server of the long connection, and when the server of the long connection receives the feedback for the initial heartbeat time Transmitting a previous heartbeat time of the second heartbeat time to the server of the long connection;
- the initial heartbeat time is used to try, that is, the long-connected client transmits the initial heartbeat time to the long-connected server to detect Whether the long-connected client will receive the long-connected server returns the initial heartbeat time.
- the long-connected client may transmit the initial heartbeat time to the long-connected server multiple times, and perform corresponding processing according to whether the preset number of feedbacks of the server that receives the long-connection is received on time. For example, a client with a long connection can transmit the initial heartbeat time 5 times to the server of the long connection. When the feedback of the server that receives the long connection on time is 5 or 4 times, the server that successfully receives the long connection is successfully received. Feedback, otherwise it fails.
- the process proceeds to step 1 to re-initialize the heartbeat time.
- the previous heartbeat time of the second heartbeat time is used to try, that is, the previous heartbeat time of the second heartbeat time is transmitted to the long-connected service. end.
- the second heartbeat time is the inverse of the second heartbeat time of the server that does not receive the long connection.
- the second heartbeat time that was last sent. The number of times the previous heartbeat time is transmitted can be flexibly set according to the specific situation, and corresponding processing is performed according to whether the preset number of feedbacks of the server that receives the long connection on time is satisfied.
- Step S4 After receiving the feedback of the server of the long connection, calculate an initial heartbeat increase step according to the second heartbeat time and the previous heartbeat time;
- the process proceeds to step 1 to re-initialize the heartbeat time.
- B 0 represents an initial heart rate increase in step length
- f (n) represents a second heartbeat time
- f (n-1) represents a second heartbeat time before the time of a heartbeat.
- Step S5 Calculate a third heartbeat time according to the initial heartbeat increase step size and the second heartbeat time, calculate a new heartbeat increase step size according to the initial heartbeat increase step size, and calculate according to the new heartbeat increase step size and the third heartbeat time.
- the fourth heartbeat time is until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- B n represents a new heartbeat increase step size
- B n-1 represents a previous heartbeat increase step size of the new heartbeat increase step.
- the optimal value can be quickly found.
- the long-connected client sends the obtained third heartbeat time to the server of the long connection, and when receiving the feedback of the server with the long connection, increments n by 1 step, and calculates the fourth heartbeat according to the formula. time.
- the process proceeds to step S3, and the initial heartbeat time is retransmitted to the server of the long connection to try.
- the long-connected client then sends the obtained fourth heartbeat time to the long-connected server, and when receiving the feedback of the long-connected server for the fourth heartbeat time, increments n to continue calculating the fourth heartbeat time until it is obtained.
- the fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- the long-connected heartbeat time acquisition device of this embodiment includes:
- the initial heartbeat time acquisition module 100 is configured to determine an initial heartbeat time according to a current network environment
- the long-connected client After the long-connected client establishes a connection with the long-connected server, the long-connected client sends its own related information to the long-connected server, and the long-connected server identifies the long-connected client to complete the long The process of connecting the server to the line initialization.
- the long-connected client Since the initial heartbeat time is related to the network environment, the long-connected client initializes the initial heartbeat time according to the current network environment in which the terminal is located by detecting the current network environment.
- the default initial value can be set to 10 to 50 seconds, or can be flexibly set according to the specific situation.
- the second heartbeat time acquisition module 200 is configured to calculate a first heartbeat time according to the initial heartbeat time, and transmit the first heartbeat time to the server of the long connection, and receive feedback of the server of the long connection Calculating the second heartbeat time with the first heartbeat time as the new initial heartbeat time, and continuing to send the second heartbeat time to the server of the long connection until the feedback of the server of the long connection is not received;
- the long-connected client obtains the first heartbeat time, the first heartbeat time is transmitted to the long-connected server.
- the step increment is repeated to calculate the second heartbeat time according to the formula.
- the obtained second heartbeat time is continuously sent to the server of the long connection until the feedback of the server of the long connection is not received, and the calculation of the second heartbeat time by the above formula is stopped.
- the feedback of the server that is connected to the long connection may be the heartbeat time sent by the client that returns the long connection, or may return the specified information according to a preset protocol.
- the second heartbeat time is repeatedly calculated by the above formula, so that in the process of finding the optimal heartbeat time, when the heartbeat time increases rapidly, the critical value of the heartbeat time is found as few times as possible.
- the long-connected client can The first heartbeat time or the second heartbeat time is transmitted to the server of the long connection multiple times.
- the preset number of transmissions of transmitting the first heartbeat time or the second heartbeat time to the server of the long connection does not satisfy the preset number of times of receiving the server feedback of the long connection, it is determined that the feedback of the server of the long connection is not received.
- the preset number of transmissions and the preset number of times can be flexibly set according to specific conditions. For example, a long-connected client transmits the first heartbeat time 3 times to a long-connected server. If the server receives a long-connected server feedback 3 times, the long-connected client will be the first. When a heartbeat time is sent to the server of the long connection, the feedback of the server of the long connection can be successfully received.
- the transmitting module 300 is configured to transmit the initial heartbeat time to the server of the long connection when the feedback of the server of the long connection is not received, and the initial heartbeat time of the server that receives the long connection The feedback, transmitting the previous heartbeat time of the second heartbeat time to the server of the long connection;
- the initial heartbeat time is used to try, that is, the long-connected client calls the transmitting module 300 to transmit the initial heartbeat time to the long-connected service. End, to detect whether the long-connected client will receive the long-connected server to return the initial heartbeat time.
- the long-connected client may transmit the initial heartbeat time to the long-connected server multiple times, and perform corresponding processing according to whether the preset number of feedbacks of the server that receives the long-connection is received on time. For example, a client with a long connection can transmit the initial heartbeat time 5 times to the server of the long connection. When the feedback of the server that receives the long connection on time is 5 or 4 times, the server that successfully receives the long connection is successfully received. Feedback, otherwise it fails.
- the heartbeat time is re-initialized.
- the previous heartbeat time of the second heartbeat time is used, that is, the transmission module 300 transmits the previous heartbeat time of the second heartbeat time.
- the second heartbeat time is the last heartbeat time that is sent when the server that receives the long connection does not receive feedback for the second heartbeat time.
- the number of times the previous heartbeat time is transmitted can be flexibly set according to the specific situation, and corresponding processing is performed according to whether the preset number of feedbacks of the server that receives the long connection on time is satisfied.
- the initial heartbeat increase step size obtaining module 400 is configured to calculate an initial heartbeat increase step size according to the second heartbeat time and the previous heartbeat time after receiving the feedback of the long-connected server;
- the heartbeat time is re-initialized.
- B 0 represents an initial heart rate increase in step length
- f (n) represents a second heartbeat time
- f (n-1) represents a second heartbeat time before the time of a heartbeat.
- the fourth heartbeat time acquisition module 500 is configured to calculate a third heartbeat time according to the initial heartbeat increase step size and the second heartbeat time, calculate a new heartbeat increase step size according to the initial heartbeat increase step size, and increase the step size according to the new heartbeat Calculating the fourth heartbeat time with the third heartbeat time until the obtained fourth heartbeat time reaches a preset limit value or the heartbeat increase step is zero, and the fourth heartbeat time at this time is used as the survival heartbeat time for maintaining the long connection. .
- the initial heartbeat time is resently sent to the server of the long connection to try.
- the long-connected client then sends the obtained fourth heartbeat time to the long-connected server, and when receiving the feedback of the long-connected server for the fourth heartbeat time, increments n to continue calculating the fourth heartbeat time until it is obtained.
- the fourth heartbeat time reaches a preset limit value or the heartbeat increase step size is zero, and the fourth heartbeat time at this time is taken as the survival heartbeat time for maintaining the long connection.
- the present invention provides a terminal that includes the long-connected heartbeat time acquisition device of the above structure, that is, includes an initial heartbeat time acquisition module 100, a second heartbeat time acquisition module 200, a transmission module 300, and an initial heartbeat increase step size.
- the obtaining module 400 and the fourth heartbeat time obtaining module 500 are the terminals.
- the terminal can be a mobile phone, a computer, a smart TV, or the like.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Data Mining & Analysis (AREA)
- Telephonic Communication Services (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
Description
Claims (20)
- 一种多业务共享长连接方法,其特征在于,所述多业务共享长连接方法包括以下步骤:长连接的客户端建立用于传输数据至长连接的服务端的通道,并获取心跳时间维持长连接的存活;长连接的服务端根据各业务的申请请求为各业务配置唯一的业务ID,并将所述业务ID发送至长连接的客户端;长连接的客户端将接收到的所述业务ID传送至对应的业务客户端,以供其上报至与其对应的业务服务端;长连接的服务端在接收到业务服务端推送的业务信息后,根据业务ID通过所述通道将业务信息发送至长连接的客户端;长连接的客户端根据业务ID将业务信息推送至业务客户端。
- 如权利要求1所述的多业务共享长连接方法,其特征在于,所述长连接的服务端根据各业务的申请请求为各业务配置唯一的业务ID并发送至长连接的客户端包括:长连接的服务端接收各业务发送的业务标示申请请求,并根据该业务标示申请请求返回业务标示至业务客户端;长连接的客户端接收业务客户端发送的业务标示,并根据长连接的客户端所在终端的属性信息建立用以识别终端的唯一的特征值,将所述各个业务标示和特征值一起传送至所述长连接的服务端;长连接的服务端根据所述业务标示和特征值生成与各个业务对应的业务ID,并将所述业务ID发送至长连接的客户端。
- 如权利要求1所述的多业务共享长连接方法,其特征在于,所述长连接的客户端建立用于传输数据至长连接的服务端的通道,并获取心跳时间维持长连接的存活包括:根据当前的网络环境确定初始心跳时间;根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时 间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈;在未接收到所述长连接的服务端的反馈时,将所述初始心跳时间传送至所述长连接的服务端,在接收到所述长连接的服务端针对初始心跳时间的反馈时,将第二心跳时间的前一次心跳时间传送至所述长连接的服务端;接收到所述长连接的服务端的反馈后,根据所述第二心跳时间与所述前一次心跳时间计算初始心跳增加步长;根据初始心跳增加步长及所述第二心跳时间计算第三心跳时间,根据初始心跳增加步长计算新的心跳增加步长,根据新的心跳增加步长和第三心跳时间计算得到第四心跳时间,直至得到的第四心跳时间达到预设的极限值或者心跳增加步长为零,将此时的第四心跳时间作为维持长连接的存活的心跳时间。
- 如权利要求3所述的多业务共享长连接方法,其特征在于,按以下公式计算心跳时间:f(n)=2*f(n-1);其中,n≥1,初始心跳时间f(0)为10~50秒;当n=1时,得到第一心跳时间为f(1)=2*f(0);当n递增时,得到第二心跳时间。
- 如权利要求4所述的多业务共享长连接方法,其特征在于,按以下公式计算初始心跳增加步长:B0=(f(n)-f(n-1))/2;其中,n≥1,B0表示初始心跳增加步长,f(n)表示第二心跳时间,f(n-1)表示第二心跳时间的前一次心跳时间;按以下公式计算新的心跳增加步长:Bn=(Bn-1)/2;其中,n≥1,Bn表示新的心跳增加步长,Bn-1表示新的心跳增加步长的前一次心跳增加步长;按以下公式计算第三心跳时间和第四心跳时间:f′(n)=f′(n-1)+Bn;其中,n≥1,当n=1时,计算得到的第三心跳时间;当n递增时,得到第四心跳时间。
- 如权利要求3所述的多业务共享长连接方法,其特征在于,所述根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈包括:当将第一心跳时间或第二心跳时间传送至所述长连接的服务端的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 如权利要求5所述的多业务共享长连接方法,其特征在于,所述根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈包括:当将第一心跳时间或第二心跳时间传送至所述长连接的服务端的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 一种多业务共享长连接系统,其特征在于,所述多业务共享长连接系统包括长连接的客户端和长连接的服务端,其中,长连接的客户端,用于建立用于传输数据至长连接的服务端的通道,并获取心跳时间维持长连接的存活;长连接的服务端,用于根据各业务的申请请求为各业务配置唯一的业务ID,并将所述业务ID发送至长连接的客户端;长连接的客户端,用于将接收到的所述业务ID传送至对应的业 务客户端,以供其上报至与其对应的业务服务端;长连接的服务端,用于在接收到业务服务端推送的业务信息后,根据业务ID通过所述通道将业务信息发送至长连接的客户端;长连接的客户端,用于根据业务ID将业务信息推送至业务客户端。
- 如权利要求8所述的多业务共享长连接系统,其特征在于,所述长连接的服务端,还用于接收各业务发送的业务标示申请请求,并根据该业务标示申请请求返回业务标示至业务客户端;长连接的客户端,还用于接收业务客户端发送的业务标示,并根据长连接的客户端所在终端的属性信息建立用以识别终端的唯一的特征值,将所述各个业务标示和特征值一起传送至所述长连接的服务端;长连接的服务端,还用于根据所述业务标示和特征值生成与各个业务对应的业务ID,并将所述业务ID发送至长连接的客户端。
- 一种长连接的心跳时间获取方法,其特征在于,所述长连接的心跳时间获取方法包括以下步骤:根据当前的网络环境确定初始心跳时间;根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈;在未接收到所述长连接的服务端的反馈时,将所述初始心跳时间传送至所述长连接的服务端,在接收到所述长连接的服务端针对初始心跳时间的反馈时,将第二心跳时间的前一次心跳时间传送至所述长连接的服务端;接收到所述长连接的服务端的反馈后,根据所述第二心跳时间与所述前一次心跳时间计算初始心跳增加步长;根据初始心跳增加步长及所述第二心跳时间计算第三心跳时间,根据初始心跳增加步长计算新的心跳增加步长,根据新的心跳增加步长和第三心跳时间计算得到第四心跳时间,直至得到的第四心跳时间达到预设的极限值或者心跳增加步长为零,将此时的第四心跳时间作为维持长连接的存活的心跳时间。
- 如权利要求10所述的长连接的心跳时间获取方法,其特征在于,按以下公式计算心跳时间:f(n)=2*f(n-1);其中,n≥1,初始心跳时间f(0)为10~50秒;当n=1时,得到第一心跳时间为f(1)=2*f(0);当n递增时,得到第二心跳时间。
- 如权利要求11所述的长连接的心跳时间获取方法,其特征在于,按以下公式计算初始心跳增加步长:B0=(f(n)-f(n-1))/2;其中,n≥1,B0表示初始心跳增加步长,f(n)表示第二心跳时间,f(n-1)表示第二心跳时间的前一次心跳时间;按以下公式计算新的心跳增加步长:Bn=(Bn-1)/2;其中,n≥1,Bn表示新的心跳增加步长,Bn-1表示新的心跳增加步长的前一次心跳增加步长;按以下公式计算第三心跳时间和第四心跳时间:f′(n)=f′(n-1)+Bn;其中,n≥1,当n=1时,计算得到的第三心跳时间;当n递增时,得到第四心跳时间。
- 如权利要求10所述的长连接的心跳时间获取方法,其特征在于,所述所述根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈包括:当将第一心跳时间或第二心跳时间传送至所述长连接的服务端 的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 如权利要求12所述的长连接的心跳时间获取方法,其特征在于,所述所述根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈包括:当将第一心跳时间或第二心跳时间传送至所述长连接的服务端的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 一种长连接的心跳时间获取装置,其特征在于,所述长连接的心跳时间获取装置包括:初始心跳时间获取模块,用于根据当前的网络环境确定初始心跳时间;第二心跳时间获取模块,用于根据所述初始心跳时间计算第一心跳时间,并将所述第一心跳时间传送至所述长连接的服务端,接收到所述长连接的服务端的反馈时,以第一心跳时间作为新的初始心跳时间计算第二心跳时间,继续发送第二心跳时间至长连接的服务端,直至接收不到所述长连接的服务端的反馈;传送模块,用于在未接收到所述长连接的服务端的反馈时,将所述初始心跳时间传送至所述长连接的服务端,在接收到所述长连接的服务端针对初始心跳时间的反馈时,将第二心跳时间的前一次心跳时间传送至所述长连接的服务端;初始心跳增加步长获取模块,用于接收到所述长连接的服务端的反馈后,根据所述第二心跳时间与所述前一次心跳时间计算初始心跳增加步长;第四心跳时间获取模块,用于根据初始心跳增加步长及所述第二 心跳时间计算第三心跳时间,根据初始心跳增加步长计算新的心跳增加步长,根据新的心跳增加步长和第三心跳时间计算得到第四心跳时间,直至得到的第四心跳时间达到预设的极限值或者心跳增加步长为零,将此时的第四心跳时间作为维持长连接的存活的心跳时间。
- 如权利要求15所述的长连接的心跳时间获取装置,其特征在于,按以下公式计算心跳时间:f(n)=2*f(n-1);其中,n≥1,初始心跳时间f(0)为10~50秒;当n=1时,得到第一心跳时间为f(1)=2*f(0);当n递增时,得到第二心跳时间。
- 如权利要求16所述的长连接的心跳时间获取装置,其特征在于,按以下公式计算初始心跳增加步长:B0=(f(n)-f(n-1))/2;其中,n≥1,B0表示初始心跳增加步长,f(n)表示第二心跳时间,f(n-1)表示第二心跳时间的前一次心跳时间;按以下公式计算新的心跳增加步长:Bn=(Bn-1)/2;其中,n≥1,Bn表示新的心跳增加步长,Bn-1表示新的心跳增加步长的前一次心跳增加步长;按以下公式计算第三心跳时间和第四心跳时间:f′(n)=f′(n-1)+Bn;其中,n≥1,当n=1时,计算得到的第三心跳时间;当n递增时,得到第四心跳时间。
- 如权利要求15所述的长连接的心跳时间获取装置,其特征在于,所述第二心跳时间获取模块还用于,当将第一心跳时间或第二心跳时间传送至所述长连接的服务端的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 如权利要求17所述的长连接的心跳时间获取装置,其特征在于,所述第二心跳时间获取模块还用于,当将第一心跳时间或第二 心跳时间传送至所述长连接的服务端的预设传送次数未满足接收到所述长连接的服务端反馈的预置次数,则确定未接收到所述长连接的服务端的反馈。
- 一种终端,其特征在于,所述终端包括如权利要求15所述的长连接的心跳时间获取装置。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
AU2015400309A AU2015400309B2 (en) | 2015-09-08 | 2015-12-18 | Long connection sharing method for multi-businesses, system and device, terminal |
US15/414,627 US10263872B2 (en) | 2015-09-08 | 2017-01-25 | Long connection sharing method for multi-businesses, system and device, terminal |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510567873.5 | 2015-09-08 | ||
CN201510567873.5A CN105227398B (zh) | 2015-09-08 | 2015-09-08 | 多业务共享长连接方法、系统及其装置、终端 |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US15/414,627 Continuation US10263872B2 (en) | 2015-09-08 | 2017-01-25 | Long connection sharing method for multi-businesses, system and device, terminal |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2017041381A1 true WO2017041381A1 (zh) | 2017-03-16 |
Family
ID=54996108
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2015/097955 WO2017041381A1 (zh) | 2015-09-08 | 2015-12-18 | 多业务共享长连接方法、系统及其装置、终端 |
Country Status (4)
Country | Link |
---|---|
US (1) | US10263872B2 (zh) |
CN (1) | CN105227398B (zh) |
AU (1) | AU2015400309B2 (zh) |
WO (1) | WO2017041381A1 (zh) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111092809A (zh) * | 2019-12-30 | 2020-05-01 | 北京每日优鲜电子商务有限公司 | 实时推送信息的方法、装置、计算机设备及存储介质 |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106911795A (zh) * | 2017-03-27 | 2017-06-30 | 努比亚技术有限公司 | 一种数据请求处理装置及方法 |
CN109547511B (zh) * | 2017-09-22 | 2022-02-22 | 中国移动通信集团浙江有限公司 | 一种web消息实时推送方法、服务器、客户端及系统 |
CN108763200A (zh) * | 2018-05-15 | 2018-11-06 | 达而观信息科技(上海)有限公司 | 中文分词方法及装置 |
CN109286665B (zh) * | 2018-09-17 | 2021-04-20 | 北京龙拳风暴科技有限公司 | 实时移动游戏长链接处理方法及装置 |
CN114205270B (zh) * | 2020-09-17 | 2023-09-22 | 北京三快在线科技有限公司 | 设备状态确定方法、装置、存储介质及电子设备 |
CN112187899B (zh) * | 2020-09-18 | 2022-05-06 | 北京金山云网络技术有限公司 | 云托管通信方法、装置、系统、计算机设备和存储介质 |
CN112383617A (zh) * | 2020-11-12 | 2021-02-19 | 百度在线网络技术(北京)有限公司 | 进行长连接的方法、装置、终端设备以及介质 |
CN115396313A (zh) * | 2022-08-22 | 2022-11-25 | 度小满科技(北京)有限公司 | 通信方法、装置、存储介质及电子装置 |
CN116600016A (zh) * | 2023-07-19 | 2023-08-15 | 苏州浪潮智能科技有限公司 | 站点调用方法及装置、存储介质及电子装置 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080165796A1 (en) * | 2007-01-05 | 2008-07-10 | International Business Machines Corporation | Method for a heartbeat algorithm for a dynamically changing network environment |
CN103139303A (zh) * | 2013-02-07 | 2013-06-05 | 网易(杭州)网络有限公司 | 一种用于保持连接的心跳方法、装置及系统 |
CN103916442A (zh) * | 2013-01-07 | 2014-07-09 | 阿里巴巴集团控股有限公司 | 消息推送实现方法、移动终端及消息推送系统 |
CN103986740A (zh) * | 2013-02-07 | 2014-08-13 | 中兴通讯股份有限公司 | 一种支持多终端应用的永远在线架构的方法及设备及系统 |
CN104144159A (zh) * | 2014-06-26 | 2014-11-12 | 腾讯科技(深圳)有限公司 | 智能心跳保活方法及智能心跳保活系统 |
CN104767775A (zh) * | 2014-01-06 | 2015-07-08 | 腾讯科技(深圳)有限公司 | 网页应用消息推送方法及系统 |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4509536B2 (ja) * | 2003-11-12 | 2010-07-21 | 株式会社日立製作所 | 情報管理を支援する情報処理装置、情報管理方法、プログラム、および記録媒体 |
US20090251283A1 (en) * | 2006-05-02 | 2009-10-08 | Orient Instrument Computer Co., Ltd. | Property management system |
WO2009061399A1 (en) * | 2007-11-05 | 2009-05-14 | Nagaraju Bandaru | Method for crawling, mapping and extracting information associated with a business using heuristic and semantic analysis |
CN102291808B (zh) * | 2011-06-03 | 2013-12-04 | 莫雅静 | 一种网络通信方法、通信设备以及通信设备的中间件 |
CN103684815B (zh) * | 2012-09-03 | 2017-02-01 | 中国移动通信集团公司 | 数据传输链路的保活方法、装置及系统 |
US10475075B2 (en) * | 2013-03-15 | 2019-11-12 | Marchex, Inc. | Correlated consumer telephone numbers and user identifiers for advertising retargeting |
CN103685241A (zh) * | 2013-11-26 | 2014-03-26 | 中国科学院计算技术研究所 | 一种维持tcp长连接的自适应心跳方法及其系统 |
US20150301875A1 (en) * | 2014-04-22 | 2015-10-22 | Andreas Harnesk | Persisting and managing application messages |
-
2015
- 2015-09-08 CN CN201510567873.5A patent/CN105227398B/zh active Active
- 2015-12-18 WO PCT/CN2015/097955 patent/WO2017041381A1/zh active Application Filing
- 2015-12-18 AU AU2015400309A patent/AU2015400309B2/en active Active
-
2017
- 2017-01-25 US US15/414,627 patent/US10263872B2/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080165796A1 (en) * | 2007-01-05 | 2008-07-10 | International Business Machines Corporation | Method for a heartbeat algorithm for a dynamically changing network environment |
CN103916442A (zh) * | 2013-01-07 | 2014-07-09 | 阿里巴巴集团控股有限公司 | 消息推送实现方法、移动终端及消息推送系统 |
CN103139303A (zh) * | 2013-02-07 | 2013-06-05 | 网易(杭州)网络有限公司 | 一种用于保持连接的心跳方法、装置及系统 |
CN103986740A (zh) * | 2013-02-07 | 2014-08-13 | 中兴通讯股份有限公司 | 一种支持多终端应用的永远在线架构的方法及设备及系统 |
CN104767775A (zh) * | 2014-01-06 | 2015-07-08 | 腾讯科技(深圳)有限公司 | 网页应用消息推送方法及系统 |
CN104144159A (zh) * | 2014-06-26 | 2014-11-12 | 腾讯科技(深圳)有限公司 | 智能心跳保活方法及智能心跳保活系统 |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111092809A (zh) * | 2019-12-30 | 2020-05-01 | 北京每日优鲜电子商务有限公司 | 实时推送信息的方法、装置、计算机设备及存储介质 |
CN111092809B (zh) * | 2019-12-30 | 2022-08-16 | 北京每日优鲜电子商务有限公司 | 实时推送信息的方法、装置、计算机设备及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
US20170134256A1 (en) | 2017-05-11 |
AU2015400309B2 (en) | 2020-07-09 |
US10263872B2 (en) | 2019-04-16 |
CN105227398A (zh) | 2016-01-06 |
CN105227398B (zh) | 2018-09-04 |
AU2015400309A1 (en) | 2017-03-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017041381A1 (zh) | 多业务共享长连接方法、系统及其装置、终端 | |
CN103069755B (zh) | 使用多个客户端实例的即时消息传送的方法和系统 | |
CN107181804B (zh) | 资源的下载方法和装置 | |
CN102457784B (zh) | 在EPON+EoC网络中对EoC设备软件进行批量升级的方法 | |
KR20050077688A (ko) | 클라이언트 단말장치와 서버 사이의 세션 재설정을 위한시스템 및 방법 | |
CN111510325B (zh) | 报警信息推送方法、服务器、客户端及系统 | |
RU2008138577A (ru) | Сетевая система | |
CN104601702A (zh) | 集群远程过程调用方法及系统 | |
CN109474718A (zh) | 域名解析方法和装置 | |
CN109525620B (zh) | 一种消息推送系统、方法及装置 | |
WO2022068463A1 (en) | Network node, terminal device, and methods therein for edge applications | |
WO2015027721A1 (zh) | 一种终端状态订阅方法、装置及系统 | |
CN113765774B (zh) | 消息实时同步方法、装置、电子设备及介质 | |
WO2013189398A2 (zh) | 应用数据推送方法、装置及系统 | |
CN102710810A (zh) | 一种自动分配ip地址的方法及一种中继设备 | |
CN104065656A (zh) | 一种媒体流数据识别方法 | |
CN104735401A (zh) | 一种多个视频监控平台的统一网管方法 | |
CN107370731B (zh) | 基于自然语言实现不同应用之间通信的方法及装置 | |
CN112839108B (zh) | 连接建立方法、装置、设备、数据网络及存储介质 | |
CN111726417B (zh) | 延时控制方法、装置、服务器及存储介质 | |
CN107395583B (zh) | 基于自然语言实现不同应用之间通信的方法及装置 | |
US10951501B1 (en) | Monitoring availability of content delivery networks | |
CN111314492A (zh) | 空调器及其数据传输方法和计算机可读存储介质 | |
CN111092805A (zh) | 基于dht网络的即时通信方法、装置、设备和介质 | |
CN109996347B (zh) | 一种建立终端设备之间连接的方法及装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
ENP | Entry into the national phase |
Ref document number: 2015400309 Country of ref document: AU Date of ref document: 20151218 Kind code of ref document: A |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15903484 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 15903484 Country of ref document: EP Kind code of ref document: A1 |