CN109474579B - Network reconnection method and device - Google Patents
Network reconnection method and device Download PDFInfo
- Publication number
- CN109474579B CN109474579B CN201811231398.4A CN201811231398A CN109474579B CN 109474579 B CN109474579 B CN 109474579B CN 201811231398 A CN201811231398 A CN 201811231398A CN 109474579 B CN109474579 B CN 109474579B
- Authority
- CN
- China
- Prior art keywords
- client
- network connection
- target network
- operation instruction
- reconnection
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/1066—Session management
- H04L65/1083—In-session procedures
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Business, Economics & Management (AREA)
- General Business, Economics & Management (AREA)
- Multimedia (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the invention discloses a network reconnection method, which enables a server to quickly identify a client before disconnection through unique identification information established between the server and the client, and recovers the operation of the client before disconnection according to a recovery algorithm, so that the client and the server can be connected in a short time, and the client can keep the state and the operation steps before disconnection. Even if the user frequently interrupts the network due to the switching of the base station serving the client in the moving process, the client of the user can be simply and effectively reconnected to the network without complex operation and long reloading time waiting, so that the user can simply and conveniently reconnect the network, and good internet surfing experience is provided. The invention also provides a network reconnection device.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for network reconnection.
Background
When a network needs to be connected to a certain client, the connection between the client and the network server can be realized based on a network connection technology (for example, socket connection technology); when the client and the network server are in a connected state, data can be transmitted, and network communication is realized. However, in the connected state, connection interruption, connection timeout, network fluctuation, and the like may occur, resulting in connection interruption.
At present, for the case of network connection interruption, if the client wants to reconnect to the network server, the client needs to send a connection request to the network server again, and the network server reallocates network resources for the client according to the received connection request, and the like, to establish network connection with the client. Thus, in contrast to reestablishing a different network connection than the one before the interruption, the client is required to reinitialize the state information (e.g., reload the level information), which affects the user's experience of using the network.
However, when the user moves in a moving state, especially when the user moves along with the transportation on various transportation vehicles, the client may continuously switch the connected base station, and then, during the switching process, the network connection of the client will be frequently interrupted, resulting in the phenomenon that the client and the server are disconnected. When reconnection is performed according to the prior art, related data of a server and a client are often reinitialized, and at this time, the client is performing an urgent or important event, and network interruption and initialization will force all operations of the client to be restarted, which means that the previous operations of the client are forced to be completely stopped and restarted, which will greatly influence the working process of the client on the operating process of a user, and greatly reduce the experience of the user in using the network.
Disclosure of Invention
In order to solve the above-mentioned problem that the user experience is greatly affected due to the fact that the network is interrupted, the client and the server are reconnected and reinitialized, and all operations of the client are forced to be restarted, embodiments of the present invention provide a method for network reconnection, which enables the server to quickly identify the client before disconnection through the unique identification information established between the server and the client, and recovers the operation of the client before disconnection according to a recovery algorithm, so that the client and the server can be connected in a short time, and the client can maintain the state and operation steps before disconnection, thereby achieving the purposes that even if the user frequently interrupts the network due to the switching of the base station serving the client during the moving process, the user does not need to perform complicated operations and wait for a long reloading time, and the user client can be simply and, The reconnection is effectively carried out in the network, so that the reconnection of the network can be simply and conveniently realized by a user, and good internet experience is provided. The invention also provides a network reconnection device.
The embodiment of the invention provides the following specific technical scheme:
in a first aspect, a method for network reconnection is provided, including:
if the connection of a target network established with a client is interrupted, receiving a reconnection request sent by the client, wherein the reconnection request carries a target identifier; wherein, the target identification comprises: the client identifier which is generated in advance and corresponds to the client in the target network connection is contained;
searching the target network connection corresponding to the target identification;
and receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction set, and realizing reconnection with the target network of the client.
Optionally, the receiving an operation instruction set cached by the client when the target network connection is interrupted, and feeding back data corresponding to the operation instruction set to implement reconnection with the target network of the client specifically includes the following steps:
obtaining the disconnection time of the target network connection;
and judging the size between the disconnection time and a preset time threshold, if the disconnection time is less than or equal to the time threshold, receiving an operation instruction set cached by the client when the connection of the target network is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection of the target network with the client.
Optionally, the receiving an operation instruction set cached by the client when the target network connection is interrupted, and feeding back data corresponding to the operation instruction set to implement reconnection with the target network of the client specifically includes the following steps:
acquiring data traffic to be sent corresponding to the target network connection disconnection moment;
and judging the size relation between the data traffic and a preset data traffic threshold, if the data traffic is less than or equal to the data traffic threshold, receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection with the target network of the client.
Optionally, if the disconnection time is greater than the time threshold, initializing corresponding information of the client corresponding to the target network connection, and initializing the client identifier;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, if the data traffic is greater than the data traffic threshold, initializing corresponding information of the client in the target network connection, and initializing the client identifier;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, before feeding back data corresponding to the operation instruction set, after receiving an operation instruction set cached by the client when the target network connection is interrupted, the method further includes:
and judging whether the operation instruction set is a repeated operation instruction according to a fault-tolerant processing algorithm, if the operation instruction set is repeated, reserving one of the repeated operation instructions, and feeding back data corresponding to the operation instruction.
Optionally, the target identifier is compared with an identifier pre-stored in a hash container, so as to obtain the target network connection corresponding to the target identifier.
Optionally, whether there is a repeated operation instruction in the operation instruction set is determined according to a fault-tolerant processing algorithm of one of the following:
acquiring data information corresponding to the operation instruction set, and judging whether repeated operation exists in the operation instruction set by adopting a comparison algorithm;
or acquiring the position information included by each operation instruction in the operation instruction set, and judging whether repeated operation exists according to the position information.
In a second aspect, an apparatus for network reconnection is further provided, including:
the system comprises a receiving unit and a processing unit, wherein the receiving unit is used for receiving a reconnection request sent by a client if the connection of a target network established with the client is interrupted, and the reconnection request carries a target identifier; wherein, the target identification comprises: the client identifier which is generated in advance and corresponds to the client in the target network connection is contained;
the searching unit is used for searching the target network connection corresponding to the target identification;
and the reconnection unit is used for receiving the operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction set, and realizing reconnection with the target network of the client.
Optionally, the reconnection unit specifically includes:
the first acquisition subunit is used for acquiring the disconnection time of the target network connection;
and the first reconnection subunit is used for judging the size between the disconnection time and a preset time threshold, and if the disconnection time is less than or equal to the time threshold, receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection with the target network of the client.
Optionally, the reconnection unit specifically includes:
the second obtaining subunit is configured to obtain data traffic to be sent corresponding to the target network connection disconnection time;
and the second reconnection subunit is used for judging the size relationship between the data traffic and a preset data traffic threshold, and if the data traffic is less than or equal to the data traffic threshold, receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection with the target network of the client.
Optionally, the method further comprises: an initialization unit to:
if the disconnection time is greater than the time threshold, initializing corresponding information of the client corresponding to the target network connection, and initializing the client identification;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, the initialization unit is further configured to:
if the data traffic is greater than the data traffic threshold, initializing corresponding information of the client in the target network connection, and initializing the client identification;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, the apparatus further comprises: a fault tolerant unit comprising:
a judging subunit, configured to, before feeding back data corresponding to the operation instruction set, after receiving an operation instruction set cached by the client when connection of the target network is interrupted, judge whether the operation instruction set is a repeated operation instruction according to a fault-tolerant processing algorithm;
and the fault-tolerant subunit is used for reserving one of the repeated operation instructions and feeding back data corresponding to the operation instruction if the operation instruction set has the repetition.
Optionally, the search unit is specifically configured to: and comparing the target identification with an identification prestored in a Hash container to obtain the target network connection corresponding to the target identification.
Optionally, the determining subunit is specifically configured to:
acquiring data information corresponding to the operation instruction set, and judging whether repeated operation exists in the operation instruction set by adopting a comparison algorithm;
or acquiring the position information included by each operation instruction in the operation instruction set, and judging whether repeated operation exists according to the position information.
In the embodiment of the present invention, if a target network connection established between a network server and a client is interrupted, the client may send a reconnection request to the network server, and at this time, the network server receives a reconnection request carrying a target identifier sent by the client, where the target identifier includes: the client identifier is generated in advance and contains a client identifier corresponding to the client in the target network connection; then, the network server can search the target network connection corresponding to the target identifier according to the target identifier; and then, the network server receives an operation instruction set cached by the client when the target network connection is interrupted, and feeds back data corresponding to the operation instruction set to realize reconnection with the target network of the client. Therefore, by the network reconnection method provided by the embodiment of the invention, even if the network is frequently interrupted in the moving process of the user, the network connection is not required to be reestablished through complex operation, and longer reloading time is not required to wait, the client of the user can be simply and effectively reconnected to the network connection established by the client and the network connection established by the client, the previous user operation can be recovered in reconnection, the user can realize network reconnection almost without feeling that the network interruption occurs, and good internet surfing experience is provided for the user.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments described in the present invention, and it is obvious for those skilled in the art to obtain other drawings according to these drawings.
Fig. 1 is a flowchart illustrating a method for network reconnection according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart illustrating an exemplary method of step 103 in an embodiment of the present invention;
FIG. 3 is a schematic flow chart illustrating another exemplary method of step 103 in an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for network reconnection in an embodiment of the present invention.
Detailed Description
At present, as long as the network connection is interrupted, the client generally displays prompt messages such as "network connection is disconnected", "network connection is wrong, please try again" and the like to the user, and informs the user that the current network connection is abnormal; meanwhile, the client sends a new connection request to the network server, attempts to establish a new network connection, and needs to initialize state information after completing establishment of the new network connection (for example, for a game scene, a game level needs to be reloaded).
The inventor finds that there may be two reasons for the network connection to be interrupted: firstly, a network server or a connection path fails; and secondly, switching to the base station serving the client side when the user moves. When the network interruption is caused by the second reason, the network connection does not break down, the base station is switched continuously only along with the change of the position of the client, the reconnection of the network is realized by adopting the mode of reestablishing the new network connection, and the network access can be carried out through the newly established network connection after the switching is finished, so that on one hand, prompt information such as 'network connection error, retry' and the like is continuously popped up on the client, and the experience of a user in using the network is greatly reduced; on the other hand, more importantly, in the case of strict real-time requirement, if the state information is initialized continuously with the frequent occurrence of the phenomenon of "network interruption — new network connection establishment", for example, the game stage is reloaded continuously during the game, the game experience of the user is seriously reduced.
Based on this, the embodiment of the present invention provides a method for simply, conveniently and quickly implementing network reconnection, which enables a network server to quickly identify a client before disconnection and to recover the operation of the client before disconnection through unique identification information established between the network server and the client, so that the client and the network server can be connected in a short time, and the client can maintain the state and the operation steps before disconnection. A new network connection is not required to be reestablished, and a unique identifier capable of representing the network connection is generated according to the identifiers of the client and the network server after the network connection is established; after the network interruption occurs, the corresponding target network connection can be determined according to the unique identifier, and the cached operation instruction set during the line interruption is received, so that the established network connection and the state at the line interruption moment can be quickly recovered according to the received operation instruction set, and the user can hardly feel the network interruption, thereby improving the internet surfing experience of the user.
The following describes a specific implementation manner of a method and an apparatus for network reconnection in an embodiment of the present invention in detail by embodiments with reference to the accompanying drawings.
Referring to fig. 1, a method for network reconnection according to an embodiment of the present invention is shown. In this embodiment, the method may specifically include:
It can be understood that, before step 101, the network server is required to establish a target network connection with the client, and the process of establishing the target network connection may specifically be:
s1, the network server establishes target network connection with the client;
s2, generating a target identifier corresponding to the target network connection based on a client identifier generated by the client corresponding to the target network connection establishment and a network server identifier corresponding to the network server;
s3, saving the target identification and sending the target identification to the client so that the client can save the target identification.
Therefore, after the target network connection is established between the client and the network server, the target identification corresponding to the target network connection is stored, and the target network connection needing to be recovered between the client and the network server can be conveniently found when the target network connection is interrupted.
The client identification is used for uniquely identifying the client in the target network connection, the client identification has a life cycle, the same client establishes a new network connection with the network server every time, and the client identification uniquely corresponding to the network connection can be generated. The client side logo may specifically include: random number generated by the client, partial information code of the client, time parameter and other information.
For example: if the client establishes a network connection 1 with a network server A, the generated client identifier is a; when the ue disconnects the network connection 1 and establishes another network connection 2 with another network server B, the ue generates a ue id B corresponding to the network connection 2.
The network server identifier is used for uniquely identifying the network server side, and specifically may include: the identification code of the information (such as IP address, number, etc.) of the network server. It should be noted that, for a certain network server, no matter which client establishes network connection with the certain network server, the network server identifier corresponding to the certain network server is the same.
The target identifier may be a target identifier that is generated when the client and the network server establish a network connection for the first time and includes a client identifier and a network server identifier of the client corresponding to the target network connection, where the target identifier is used to characterize the client and the network server that are specifically connected to the target network connection for the second time.
As an example, suppose that when client a and network server B establish the connection, client a generates a 4-bit client id: xxxx, the network server identifier of 4 bits corresponding to the network server B is: yyyy, then client a informs webserver B of xxxx, and webserver B informs client a of yyyy, at which time both client a and webserver B can generate a same 8-bit target identifier: xxxxyyyy. Therefore, the effective communication between the client A and the network server B can be realized in a mode of carrying the target identification. It should be noted that, the client a may also notify the network server B of the client identifier xxxx, and after the network server B generates the target identifier xxxxyyyy, the target identifier is fed back to the client a, and the target identifier xxxxyyyy is stored in both the network server B and the client a.
It should be noted that the generation manner of the target identifier may be an identifier formed by combining the client identifier and the network server identifier according to a certain combination rule, or an identifier obtained after processing according to a certain algorithm such as encryption or compression, and is not limited in the present invention.
In some implementations, for step 101, after the target network connection is established, if the target network connection is interrupted, the client may send a reconnection request to the network server to request the network server to recover the target network connection previously established with the client.
In specific implementation, when it is detected that the currently established network connection is interrupted, the client may determine, according to a pre-stored target identifier, a network server identifier in the target identifier, determine a receiving object of the reconnection request (i.e., a network server in the target network connection), generate and send a reconnection request carrying the target identifier to the network server, so as to request to recover the interrupted target network connection.
It can be understood that, in order to provide a better network environment for a user and enable the user to hardly perceive the network interruption, when the network connection interruption occurs, the client and the network server both record and cache the current state information, and the client can cache the user operation instruction set when the target network connection is interrupted, so as to lay a data foundation for the state before the user is disconnected after the network connection is restored.
And 102, searching for target network connection corresponding to the target identification.
It can be understood that, after receiving the reconnection request, the network server may obtain the target identifier by analyzing the reconnection request, and then find the target network connection between the client and the network server corresponding to the target identifier.
In some implementations, a hash container exists in the network server, and after a network connection is established between the network server and the client, the network connection and the unique identification correspondence including the client identification can be saved in the hash container. Then, the implementation procedure of step 102 may be: and the network server compares the received target identification with the identification stored in the hash container to obtain the target network connection corresponding to the target identification. In specific implementation, the unique identifier stored in the hash container may be compared with the unique identifier in the correspondence between the network connections, and after finding the unique identifier consistent with the target identifier, the network connection in the correspondence where the unique identifier is located may be determined as the target network connection corresponding to the target identifier.
As an example, assume that client a and web server B establish network connection 1, and web server B holds the correspondence: the client identifier a is a network connection 1, and the client identifier B is a network connection 2, … …, so that after the network server B receives a reconnection request carrying a target identifier xxxxyyyy, the client identifier xxxx can be determined according to xxxxyyyy, and then a target corresponding relationship consistent with xxxx, that is, the client identifier a is a network connection 1, can be found from the stored corresponding relationship, so that the network connection 1 in the target corresponding relationship can be recorded as a target network connection. That is, the target network connection corresponding to the target identifier xxxxyyyy is found to be the network connection 1.
As another example, assume that the client a and the web server B establish a network connection 1, the corresponding target identifier is xxxxyyyy, and the web server B stores the corresponding relationship: xxxxyyyy-network connection 1, zzzzyyy-network connection 2, … …, then, after receiving a reconnect request carrying a target identifier xxxxyyy, the network server B may search for a target correspondence including xxxxyyy correspondence from the correspondence, that is, xxxxyyyy-network connection 1; next, the network connection 1 in the target correspondence is determined as a target network connection. That is, the target network connection corresponding to the target identifier xxxxyyyy is found to be the network connection 1.
It should be noted that, the searching for the target network connection corresponding to the target identifier in step 102 may be implemented by the identifier stored in the hash container, or implemented by other algorithms, and is not specifically limited in the embodiment of the present invention.
It will be appreciated that the determined target network connection, i.e., the network connection that the network server needs to restore to the client that sent the reconnect request, is ready for network reconnection.
During specific implementation, when network environment factors such as network server faults, connection paths and the like are not abnormal, the original resource configuration of target network connection can be used for restoring the target network connection with the client, the network connection before interruption is quickly and effectively reconnected, moreover, the network server can also trigger the client to restore the state before the disconnection according to the state information stored during the interruption when the reconnection is restored, a user does not need to wait for longer reloading time, the client can be made to return to the state before the disconnection unconsciously by the user, and the experience of the user on the network reconnection is optimized.
In some possible implementation manners, after the target network connection is found, the client may send the cached operation instruction set to the network server when the target network connection is interrupted; the network server determines data corresponding to user operation during disconnection according to the received operation instruction set, namely the data corresponding to the operation instruction set; the network server may then effect a target network reconnection with the client based on the data.
In other possible implementations, after the target network connection is found, the target network connection with the client may also be restored first. After the target network connection is recovered, in order to provide better user experience, the network server can also wait for receiving an operation instruction set which is sent by the client and cached when the target network connection is interrupted, and once the operation instruction set is received, the network server can determine data corresponding to the user operation when the network is disconnected, namely the data corresponding to the operation instruction set, and recover the client to the state before the disconnection according to the data corresponding to the operation instruction set.
Therefore, by the network reconnection method provided by the embodiment of the invention, even if the network is frequently interrupted in the moving process of the user, the network connection is not required to be reestablished through complex operation, and longer reloading time is not required to wait, the client of the user can be simply and effectively reconnected to the network connection established by the client and the network connection established by the client, the previous user operation can be recovered in reconnection, the user can realize network reconnection almost without feeling that the network interruption occurs, and good internet surfing experience is provided for the user.
It will be appreciated that the execution of step 103 may also be based on certain preset conditions, and specific considerations may include: the disconnection time of the target network connection and/or the data traffic to be sent corresponding to the disconnection time of the target network connection.
As an example, as shown in fig. 2, step 103 may be performed based on the disconnection time, and specifically may include:
It is understood that the disconnection time of the target network connection refers to the time that elapses from the disconnection of the target network connection to the reconnection of the target network.
It is understood that the implementation manner of step 203 may refer to the related description of step 103, and is not described herein again.
In order to deal with an emergency situation, such as an interruption, the network server generally caches state information within a preset time (e.g., 2 minutes), and the client may further store a user operation instruction set during disconnection.
It is understood that the status information may be, for example: and displaying the state, the user data and the like of the interface of the client within preset time before disconnection. The user operation instruction set during the disconnection may be that the user does not know that the interruption occurred during the disconnection, and still performs some user operation on the client. And the initialization instruction is used for indicating that the client can perform other operations after waiting for reloading the initial state information and the like after restoring the target network connection.
The preset time threshold may be used to indicate a maximum disconnection time that allows no initialization after resuming network reconnection.
In specific implementation, when the disconnection time is less than or equal to the preset time threshold, it indicates that the disconnection time is short, and then, considering that the amount of data generated in the disconnection period is small, even if the corresponding state is directly recovered to the state during the interruption, the reliability of the target network connection is not affected, at this time, in order to provide a better user experience, the network server may directly instruct the client to directly recover to the state before the disconnection according to the state information before the disconnection, and perform the user operation in the disconnection period cached by the client; or, for more reliability, the network server may send the cached state information to the client, and instruct the client to restore to the state before the line break according to the state information before the line break stored by the client and the received state information sent by the network server, and perform the user operation during the line break cached by the client.
When the disconnection time is greater than the preset time threshold, the disconnection time is longer, and then, considering that the amount of data generated in the longer disconnection period is larger, the data is more important and other factors, part of user experience can be sacrificed to perform initialization operation, so that the reliability of target network connection after the network is reconnected is ensured. The initialization specifically comprises the following steps: first, initializing relevant information of the client, for example: client device number, version number, reconnection start time and other information related to the client; secondly, initializing a client identifier, namely, indicating the client to regenerate the client identifier corresponding to the target network connection, informing a network server, generating a new unique identifier by combining the network server identifier, and respectively storing the new unique identifier in the client and the network server.
It should be noted that, in step 204, the initialization operation may be specifically based on: if the target network connection corresponding to the target identifier is found to fail for multiple times according to step 102, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
When the target network connection corresponding to the target identifier is not found, it indicates that the target network connection already established between the target network connections cannot be recovered due to data loss or other reasons, at this time, the condition of reconnection failure can be notified to the client through the indication information, and the initialization of the client identification and the relevant information of the client is realized according to the description of the initialization, so as to establish a new network connection later.
Therefore, the initialization operation during reconnection or the user operation of directly recovering to the state before disconnection and caching during disconnection is judged according to the disconnection time, so that under the condition that the network is frequently interrupted during the moving process of the user, the client of the user can be simply and effectively reconnected to the network connection established by the client and the server, the reliability of the user operation before reconnection is ensured by judging the disconnection time, the user can realize network reconnection almost without feeling the network interruption, and good internet experience is provided for the user.
As an example, as shown in fig. 3, step 103 may be performed based on the disconnection time, and specifically may include:
It can be understood that, the target network connection is disconnected, that is, at the time of disconnection, the client needs to send data traffic corresponding to the operation instruction set to the network server through the target network connection.
It is understood that the implementation manner of step 303 may refer to the related description of step 103, and is not described herein again.
The set data traffic threshold may be used to indicate the data traffic generated during the maximum disconnection period that is allowed to be initialized after the network reconnection is resumed.
In a specific implementation, when the data traffic is less than or equal to the preset data traffic threshold, the corresponding state during the interruption is directly restored, and the reliability of the target network connection is not affected, at this time, in order to provide a better user experience, the network server may directly instruct the client to directly restore to the state before the disconnection according to the state information before the disconnection, and perform the user operation during the disconnection cached by the client. When the data flow is larger than the preset data flow threshold, the data flow generated during disconnection is larger, and the situation that the data is more important may exist, so that part of user experience can be sacrificed to perform initialization operation, and the reliability of target network connection after network reconnection is ensured.
It should be noted that, in step 304, the initialization operation may be specifically based on: if the target network connection corresponding to the target identifier is found to fail for multiple times according to step 102, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
No matter the initialization operation is performed or the state before the disconnection is recovered and the user operation are performed, reference may be made to the description of relevant parts in fig. 2, which is not described herein again.
Therefore, whether initialization operation is carried out during reconnection or user operation which is directly recovered to a state before disconnection and is cached during disconnection is judged according to the size of data traffic to be sent corresponding to the disconnection moment of target network connection, and under the condition that frequent network interruption occurs in the moving process of a user, not only can the client of the user be simply and effectively reconnected to the network connection established by the client and the server, but also the reliability of the user operation before recovery during reconnection can be ensured by judging the data traffic, the user can hardly feel that network interruption occurs, network reconnection is already realized, and good internet experience is provided for the user.
It should be noted that, when the disconnection time is less than or equal to the preset time threshold, and the network server performs the user operation during the disconnection of the client cache, the embodiment of the present invention further considers: when the network connection is suddenly interrupted, the user may repeatedly trigger a certain user operation because the user feels that the screen is jammed or the operation has no feedback. Then, when determining that the client is to be directly controlled to recover to the state before the disconnection and perform the user operation during the disconnection, the embodiment of the present invention may further perform fault tolerance processing on an operation instruction set during the disconnection, specifically including: and judging whether the operation instruction set is a repeated operation instruction according to a fault-tolerant processing algorithm, if the operation instruction set is repeated, reserving one of the repeated operation instructions, and feeding back data corresponding to the operation instruction.
And judging whether a user operation belongs to a repeated operation instruction in a user operation instruction set during the disconnection period sent by the client side is received. The specific judgment mode can adopt a fault-tolerant processing algorithm:
in some implementations, whether there are duplicate operation instructions in the operation instruction set may be determined according to a fault-tolerant processing algorithm of one of the following: firstly, acquiring data information corresponding to the operation instruction set, and judging whether repeated operation exists in the operation instruction set by adopting a comparison algorithm; secondly, acquiring position information included by each operation instruction in the operation instruction set, and judging whether repeated operation exists according to the position information; thirdly, acquiring the operation times of each user operation, and judging whether the operation is repeated according to the operation times.
It can be understood that, when the number of times of operations triggered by the user during the disconnection is greater than the preset number threshold, it is determined that the user operation is a repeat operation, and then the network server controls to execute the first user operation once after the target network connection is restored; and when the operation times that the user triggers the user operation during the disconnection period is not greater than a preset time threshold value, determining that the user operation is a non-repeated operation, and controlling the network server to execute according to the cached user operation after the target network connection is recovered.
The user operation may be any one of the user operations, and the determination and the corresponding control may be performed by taking all the user operations used during the cache line disconnection period as the user operations. The preset number threshold is preset and can be used for indicating a threshold for judging that the user operation during the cache line breaking is a repeated operation.
For example, suppose that the user operations of the client cache sequentially include: the network server is controlled to execute one user operation P after target network connection is restored, and the number of the user operations P is 4 for the user operation P and is greater than the preset number threshold 3; and for the user operation Q, the operation frequency is 2, and is less than the preset frequency threshold value 3, the user operation Q is determined to be non-repeated operation, and the network server controls to execute the two user operations Q after the target network connection is recovered. That is, after the target network connection is restored, for the cached user operations, the specifically executed user operations are in turn: user operation P, user operation Q, and user operation Q.
It should be noted that, when determining to directly control the client to recover to the state before the disconnection and perform the user operation during the disconnection, the embodiment of the present invention may also have various manners of determining whether the user operation is a repetitive operation, for example: the embodiment of the invention can also comprise: judging whether the operation frequency of user operation triggered by a user during the received disconnection is greater than a preset frequency threshold value, and if so, determining that the user operation is repeated operation; and controlling to execute the user operation once after the target network connection is recovered. Another example is: the embodiment of the invention can also comprise: judging whether the operation areas of multiple user operations triggered by a user during the disconnection period are the same area, and if so, determining that the user operations are repeated operations; and controlling to execute the user operation once after the target network connection is recovered. Further manners for determining whether the user operation is a repetitive operation are not particularly limited in the present invention.
Therefore, the repeated operation can be identified through different judgment under different disconnection scenes, so that the client of the user can be simply and effectively reconnected to the network connection established by the client and the network connection, the user operation of accurately recovering during reconnection can be intelligently ensured through judging the repeated operation, the user can realize the network reconnection almost without feeling the occurrence of network interruption, and good internet surfing experience is provided for the user.
In other possible implementation manners, a reconnection failure may also occur due to a network server failure or an abnormality of a network environment such as a connection path, and then, the embodiment of the present invention may further include: when the target network connection recovery with the client meets a preset reconnection failure condition, sending prompt information to the client for informing a user of network connection failure; wherein the preset reconnection failure condition includes: the number of times that the target network connection is not recovered and the reconnection request is sent is greater than a preset number threshold, and/or the time for waiting to recover the target network connection is greater than a preset time threshold.
It is understood that, in one case, the client may periodically (for example, every 0.5 seconds) send a reconnection request to the network server after detecting the occurrence of the interruption and before resuming the target network connection, and the network server performs the above steps 101 to 103 until the network reconnection is completed. At this time, the preset reconnection failure condition may specifically have three possible situations: firstly, when the target network connection is not recovered and the number of times of sending reconnection requests is greater than a preset number threshold, the network reconnection is possibly not realized in a short time, so that the condition that the target network connection recovered with the client currently meets a preset reconnection failure condition is determined; secondly, when the time for waiting for restoring the target network connection is greater than a preset time threshold, namely, the time for waiting for restoring the target network connection from the first time when the client sends the reconnection request to the current time after the interruption occurs is greater than the preset first time threshold, the network reconnection is indicated to be possibly impossible to realize in a short time, so that the condition that the current target network connection restored by the client meets the preset reconnection failure condition is determined; thirdly, when the target network connection is not recovered and the number of times of sending reconnection requests is larger than a preset number threshold, and the time for waiting for recovering the target network connection is larger than a preset time threshold, determining that the target network connection recovered with the client currently meets a preset reconnection failure condition.
It will be appreciated that the preset threshold number of times is preset and may be used to indicate the maximum number of times that reconnection requests are allowed to be initiated during a network reconnection after an interruption. The preset time threshold is preset and can be used to represent the maximum time allowed to wait for resuming reconnection in the network reconnection process after an interruption.
When it is determined that the current target network connection restored to the client meets the preset reconnection failure condition, the network server may send a prompt message to the client to notify the user of the network connection failure. The prompt message may be a text or voice prompt message such as "network connection is interrupted", "network reconnection fails, please check your network", and the like. It should be noted that, when it is determined that the previous target network connection restoration with the client satisfies the preset reconnection failure condition, the client will not send a reconnection request to the network server any more in a short time, and waits for the instruction of the user to execute the corresponding operation.
In another case, after detecting that the interruption occurs and before resuming the target network connection, the client may send a reconnection request to the network server, and the network server executes the above steps 101 to 103 to wait for resuming the network reconnection. At this time, the preset reconnection failure condition may specifically be: when the time for waiting for recovering the target network connection is greater than a preset time threshold, the network reconnection is possibly not realized in a short time, so that the condition that the target network connection recovered with the client currently meets a preset reconnection failure condition is determined; at this time, the network server may send a prompt message to the client for informing the user of the network connection failure. The prompt message may be a text or voice prompt message such as "network connection is interrupted", "network reconnection fails, please check your network", and the like.
It should be noted that, when it is determined that the previous target network connection restoration with the client satisfies the preset reconnection failure condition, the client will not wait for the restoration of the target network connection any more, and wait for the instruction of the user to execute the corresponding operation.
It can be seen that, in the embodiment of the present invention, if a target network connection established between a network server and a client is interrupted, the client may send a reconnection request to the network server, and at this time, the network server receives a reconnection request carrying a target identifier sent by the client, where the target identifier includes: the client identifier is generated in advance and contains a client identifier corresponding to the client in the target network connection; then, the network server can search the target network connection corresponding to the target identifier according to the target identifier; and then, the network server receives an operation instruction set cached by the client when the target network connection is interrupted, and feeds back data corresponding to the operation instruction set to realize reconnection with the target network of the client. Therefore, by the network reconnection method provided by the embodiment of the invention, even if the network is frequently interrupted in the moving process of the user, the network connection is not required to be reestablished through complex operation, and longer reloading time is not required to wait, the client of the user can be simply and effectively reconnected to the network connection established by the client and the network connection established by the client, the previous user operation can be recovered in reconnection, the user can realize network reconnection almost without feeling that the network interruption occurs, and good internet surfing experience is provided for the user.
Correspondingly, referring to fig. 4, an embodiment of the present invention further provides an apparatus for network reconnection, including:
a receiving unit 401, configured to receive a reconnection request sent by a client if a connection of a target network established with the client is interrupted, where the reconnection request carries a target identifier; wherein, the target identification comprises: the client identifier which is generated in advance and corresponds to the client in the target network connection is contained;
a searching unit 402, configured to search for the target network connection corresponding to the target identifier;
a reconnection unit 403, configured to receive an operation instruction set cached by the client when the target network connection is interrupted, and feed back data corresponding to the operation instruction set, so as to implement reconnection with the target network of the client.
Optionally, the reconnection unit 403 specifically includes:
a first obtaining subunit 4031, configured to obtain disconnection time of the target network connection;
a first reconnection subunit 4032, configured to determine a size between the disconnection time and a preset time threshold, and if the disconnection time is less than or equal to the time threshold, receive an operation instruction set cached by the client when the target network connection is interrupted, and feed back data corresponding to the operation instruction, so as to implement reconnection with the target network of the client.
Optionally, the reconnection unit 403 specifically includes:
a second obtaining subunit 4033, configured to obtain data traffic to be sent corresponding to the target network connection disconnection time;
a second reconnection subunit 4034, configured to determine a size relationship between the data traffic and a preset data traffic threshold, and if the data traffic is less than or equal to the data traffic threshold, receive an operation instruction set cached by the client when the target network connection is interrupted, and feed back data corresponding to the operation instruction, so as to implement reconnection with the target network of the client.
Optionally, the method further comprises: an initialization unit 404, configured to:
if the disconnection time is greater than the time threshold, initializing corresponding information of the client corresponding to the target network connection, and initializing the client identification;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, the initialization unit 404 is further configured to:
if the data traffic is greater than the data traffic threshold, initializing corresponding information of the client in the target network connection, and initializing the client identification;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
Optionally, the apparatus further comprises: fault tolerant unit 405, comprising:
a judging subunit, configured to, before feeding back data corresponding to the operation instruction set, after receiving an operation instruction set cached by the client when connection of the target network is interrupted, judge whether the operation instruction set is a repeated operation instruction according to a fault-tolerant processing algorithm;
and the fault-tolerant subunit is used for reserving one of the repeated operation instructions and feeding back data corresponding to the operation instruction if the operation instruction set has the repetition.
Optionally, the search unit 402 is specifically configured to: and comparing the target identification with an identification prestored in a Hash container to obtain the target network connection corresponding to the target identification.
Optionally, the determining subunit is specifically configured to:
acquiring data information corresponding to the operation instruction set, and judging whether repeated operation exists in the operation instruction set by adopting a comparison algorithm;
or acquiring the position information included by each operation instruction in the operation instruction set, and judging whether repeated operation exists according to the position information.
The present embodiment is an apparatus embodiment corresponding to the foregoing network reconnection method embodiment, and a specific implementation manner and achieved technical effects may refer to the description of the foregoing network reconnection method embodiment, which is not described herein again.
The "first" in the names of "first identifier", "first user operation", and the like mentioned in the embodiments of the present invention is used only for name identification, and does not represent the first in sequence. The same applies to "second" etc.
As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by software plus a general hardware platform. With this understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM)/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network communication device such as a router, etc.) to execute the method according to the embodiments or some parts of the embodiments of the present invention.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only for the preferred embodiment of the present invention and is not intended to limit the scope of the present invention. It should be noted that, for a person skilled in the art, several modifications and refinements can be made without departing from the invention, and these modifications and refinements should be regarded as the protection scope of the present invention.
Claims (10)
1. A method of network reconnection, comprising:
if the connection of a target network established with a client is interrupted, receiving a reconnection request sent by the client, wherein the reconnection request carries a target identifier; wherein, the target identification comprises: the client identifier which is generated in advance and corresponds to the client in the target network connection is contained; the client identifier uniquely corresponds to the target network connection, and specifically includes: random numbers generated by the client, partial information codes of the client and time parameters;
searching the target network connection corresponding to the target identification;
and receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction set, and realizing reconnection with the target network of the client.
2. The method according to claim 1, wherein the receiving of the operation instruction set cached by the client when the target network connection is interrupted and feeding back data corresponding to the operation instruction set to implement reconnection with the target network of the client specifically includes:
obtaining the disconnection time of the target network connection;
and judging the size between the disconnection time and a preset time threshold, if the disconnection time is less than or equal to the time threshold, receiving an operation instruction set cached by the client when the connection of the target network is interrupted, feeding back data corresponding to the operation instruction set, and realizing reconnection with the target network of the client.
3. The method according to claim 1, wherein the receiving of the operation instruction set cached by the client when the target network connection is interrupted and feeding back data corresponding to the operation instruction set to implement reconnection with the target network of the client specifically includes:
acquiring data traffic to be sent corresponding to the target network connection disconnection moment;
and judging the size relation between the data traffic and a preset data traffic threshold, if the data traffic is less than or equal to the data traffic threshold, receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection with the target network of the client.
4. The method according to claim 2, wherein if the disconnection time is greater than the time threshold, initializing corresponding information of the client corresponding to the target network connection, and initializing the client identifier;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
5. The method of claim 3, wherein if the data traffic is greater than the data traffic threshold, initializing corresponding information of the client in the target network connection and initializing the client identifier;
or, if the target network connection corresponding to the target identifier is found for multiple times and fails, initializing corresponding information of the client corresponding to the target network connection, initializing the client identifier, and sending indication information of connection failure to the client.
6. The method according to any one of claims 1 to 5, wherein, after receiving the operation instruction set cached by the client when the target network connection is interrupted before the feeding back the data corresponding to the operation instruction set, further comprising:
and judging whether the operation instruction set is a repeated operation instruction according to a fault-tolerant processing algorithm, if the operation instruction set is repeated, reserving one of the repeated operation instructions, and feeding back data corresponding to the operation instruction.
7. The method according to claim 6, wherein the target identifier is compared with an identifier pre-stored in a hash container to obtain the target network connection corresponding to the target identifier.
8. The method of claim 7, wherein determining whether there is a duplicate operation instruction in the operation instruction set is based on a fault tolerant processing algorithm that is one of:
acquiring data information corresponding to the operation instruction set, and judging whether repeated operation exists in the operation instruction set by adopting a comparison algorithm;
or acquiring the position information included by each operation instruction in the operation instruction set, and judging whether repeated operation exists according to the position information.
9. An apparatus for network reconnection, comprising:
the system comprises a receiving unit and a processing unit, wherein the receiving unit is used for receiving a reconnection request sent by a client if the connection of a target network established with the client is interrupted, and the reconnection request carries a target identifier; wherein, the target identification comprises: the client identifier which is generated in advance and corresponds to the client in the target network connection is contained; the client identifier uniquely corresponds to the target network connection, and specifically includes: random numbers generated by the client, partial information codes of the client and time parameters;
the searching unit is used for searching the target network connection corresponding to the target identification;
and the reconnection unit is used for receiving the operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction set, and realizing reconnection with the target network of the client.
10. The apparatus according to claim 9, wherein the reconnection unit specifically includes:
the first acquisition subunit is used for acquiring the disconnection time of the target network connection;
the first reconnection subunit is configured to determine a size between the disconnection time and a preset time threshold, and if the disconnection time is less than or equal to the time threshold, receive an operation instruction set cached by the client when the target network connection is interrupted, and feed back data corresponding to the operation instruction, so as to implement reconnection with the target network of the client;
or, the reconnection unit specifically includes:
the second obtaining subunit is configured to obtain data traffic to be sent corresponding to the target network connection disconnection time;
and the second reconnection subunit is used for judging the size relationship between the data traffic and a preset data traffic threshold, and if the data traffic is less than or equal to the data traffic threshold, receiving an operation instruction set cached by the client when the target network connection is interrupted, feeding back data corresponding to the operation instruction, and realizing reconnection with the target network of the client.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811231398.4A CN109474579B (en) | 2018-10-22 | 2018-10-22 | Network reconnection method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811231398.4A CN109474579B (en) | 2018-10-22 | 2018-10-22 | Network reconnection method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109474579A CN109474579A (en) | 2019-03-15 |
CN109474579B true CN109474579B (en) | 2021-05-21 |
Family
ID=65664194
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811231398.4A Active CN109474579B (en) | 2018-10-22 | 2018-10-22 | Network reconnection method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109474579B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111385287A (en) * | 2020-02-20 | 2020-07-07 | 视联动力信息技术股份有限公司 | Network reconnection method and device for service system |
CN115550423B (en) * | 2022-04-12 | 2023-09-05 | 荣耀终端有限公司 | Data communication method, electronic device and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103024036A (en) * | 2012-12-12 | 2013-04-03 | 北京奇虎科技有限公司 | Method and device for browsing web page |
CN104270339A (en) * | 2014-09-01 | 2015-01-07 | 腾讯科技(深圳)有限公司 | Reconnection method, equipment and system for TCP (Transmission Control Protocol) connection |
CN104580537A (en) * | 2015-02-06 | 2015-04-29 | 深圳中兴网信科技有限公司 | Rapid reconnecting method based on XMPP (extensible messaging and presence protocol) client side, terminal and server |
CN105635116A (en) * | 2015-12-18 | 2016-06-01 | 网易(杭州)网络有限公司 | Reconnection methods, apparatuses and system in case of disconnection |
-
2018
- 2018-10-22 CN CN201811231398.4A patent/CN109474579B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103024036A (en) * | 2012-12-12 | 2013-04-03 | 北京奇虎科技有限公司 | Method and device for browsing web page |
CN104270339A (en) * | 2014-09-01 | 2015-01-07 | 腾讯科技(深圳)有限公司 | Reconnection method, equipment and system for TCP (Transmission Control Protocol) connection |
CN104580537A (en) * | 2015-02-06 | 2015-04-29 | 深圳中兴网信科技有限公司 | Rapid reconnecting method based on XMPP (extensible messaging and presence protocol) client side, terminal and server |
CN105635116A (en) * | 2015-12-18 | 2016-06-01 | 网易(杭州)网络有限公司 | Reconnection methods, apparatuses and system in case of disconnection |
Also Published As
Publication number | Publication date |
---|---|
CN109474579A (en) | 2019-03-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9391854B2 (en) | Method and router for packet processing during server failure | |
US10313452B2 (en) | Migrating a chat message service provided by a chat server to a new chat server | |
US20190028332A1 (en) | Configuration information push method and device | |
CN109474579B (en) | Network reconnection method and device | |
CN110691398B (en) | Network interaction method, system, equipment and storage medium of intelligent equipment | |
US20140359340A1 (en) | Subscriptions that indicate the presence of application servers | |
CN109245953B (en) | Network configuration method and device | |
CN102075545A (en) | Registration instruction method and registration method for client and equipment thereof | |
CN105721203A (en) | Upgrade processing method and device | |
CN109194521B (en) | Flow forwarding method and equipment | |
CN107104822B (en) | Server disaster recovery processing method and device, storage medium and electronic equipment | |
CN117880254A (en) | Reconnection method for real-time communication | |
EP3300418A1 (en) | Method and system for recovering communication state after sgw failure, and mme and sgw | |
CN107872822B (en) | Service bearing method and device | |
CN106067857B (en) | Method and device for preventing user from being forced off-line | |
CN111258795B (en) | Samba cluster fault reconnection method, device, equipment and medium | |
CN115412974B (en) | Shunting communication method, device, equipment and readable storage medium | |
CN106936784B (en) | SIP (Session initiation protocol) registration method, terminal and system | |
CN111756826A (en) | DLM lock information transmission method and related device | |
CN104376012A (en) | Web page application reconnection method, web page application reconnection device and web page application reconnection system | |
CN116028278A (en) | Main/standby dual-machine switching method, medium and system | |
CN107087021B (en) | Master-slave server determination method and device | |
CN105007143A (en) | Call preservation and recovery method and system | |
JP2007049318A (en) | Managed device, network management system, and information matching method | |
CN110121215B (en) | Data connection establishment method and device of 5G terminal and 5G terminal |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |