CN112929225A - Session exception handling method and device, computer equipment and storage medium - Google Patents
Session exception handling method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN112929225A CN112929225A CN202110343633.2A CN202110343633A CN112929225A CN 112929225 A CN112929225 A CN 112929225A CN 202110343633 A CN202110343633 A CN 202110343633A CN 112929225 A CN112929225 A CN 112929225A
- Authority
- CN
- China
- Prior art keywords
- session
- socket interface
- server
- client
- message
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/06—Management of faults, events, alarms or notifications
- H04L41/0654—Management of faults, events, alarms or notifications using network fault recovery
- H04L41/0663—Performing the actions predefined by failover planning, e.g. switching to standby network elements
-
- 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/143—Termination or inactivation of sessions, e.g. event-controlled end of session
- H04L67/145—Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Computer Security & Cryptography (AREA)
- Computer And Data Communications (AREA)
Abstract
The application relates to the field of cloud monitoring, and the first socket interface and the second socket interface are requested to be closed when a session is abnormal, so that a client and a server can determine that the session is abnormal more quickly and establish a socket interface for session, the session is prevented from being reestablished after overtime, and the efficiency of processing the session abnormity is improved. A method, a device, a computer device and a storage medium for processing session exception are provided, wherein the method comprises the following steps: when main network equipment corresponding to a client and a server fails, inquiring whether session information exists in standby network equipment or not; if the standby network equipment does not have session information, requesting the client to close the first socket interface and requesting the server to close the second socket interface; receiving a session request message sent by a client through a third socket interface; and sending the session request message to the server so that the server establishes a fourth socket interface. The application also relates to blockchain techniques in which session information may be stored.
Description
Technical Field
The present application relates to the field of cloud monitoring, and in particular, to a method and an apparatus for processing a session exception, a computer device, and a storage medium.
Background
The network equipment is used for forwarding the session message between the client and the server. For network devices deployed in a cluster, session information needs to be synchronized between the network devices. When the main network equipment fails, the session between the client and the server needs to be switched to the standby network equipment; if the standby network device fails to synchronize the session information successfully, the standby network device discards the session message, and the client and the server can only wait for reestablishing the session overtime, so that the application service in the client cannot process related requests in time, and the processing performance of the application service is reduced.
Therefore, when a session is abnormal, how to improve the efficiency of processing the session abnormality becomes an urgent problem to be solved.
Disclosure of Invention
The application provides a method and a device for processing session exception, computer equipment and a storage medium, wherein when main network equipment fails and standby network equipment does not have session information, a client is requested to close a first socket interface, and a server is requested to close a second socket interface, so that the client and the server can determine that the session is abnormal more quickly and establish a socket interface for session, the session is prevented from being reestablished after overtime, and the efficiency of processing the session exception is improved.
In a first aspect, the present application provides a method for processing a session exception, where the method includes:
when main network equipment corresponding to a client and a server fails, inquiring whether session information exists in standby network equipment or not, wherein the client and the server carry out session communication currently through a first socket interface of the client and a second socket interface of the server;
if the session information does not exist in the standby network equipment, requesting the client to close the first socket interface and requesting the server to close the second socket interface;
receiving a session request message sent by the client through a third socket interface, wherein the third socket interface is established when the client receives the session request message after closing the first socket interface;
and sending the session request message to the server so that the server establishes a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
In a second aspect, the present application further provides a session exception handling apparatus, including:
the session information query module is used for querying whether session information exists in the standby network equipment or not when main network equipment corresponding to a client and a server fails, wherein the client and the server carry out session communication currently through a first socket interface of the client and a second socket interface of the server;
a request closing interface module, configured to request the client to close the first socket interface and request the server to close the second socket interface if the session information does not exist in the standby network device;
a message receiving module, configured to receive a session request message sent by the client through a third socket interface, where the third socket interface is established when the client receives the session request message after closing the first socket interface;
and the message sending module is used for sending the session request message to the server so as to enable the server to establish a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
In a third aspect, the present application further provides a computer device comprising a memory and a processor;
the memory for storing a computer program;
the processor is configured to execute the computer program and implement the above-mentioned session exception handling method when executing the computer program.
In a fourth aspect, the present application also provides a computer-readable storage medium storing a computer program, which when executed by a processor causes the processor to implement the session exception handling method as described above.
The application discloses a method and a device for processing session exception, computer equipment and a storage medium, wherein when a main network device corresponding to a client and a server fails, whether session information exists in a standby network device is inquired, and when the session information exists in the standby network device, a session between the client and the server can be switched to the standby network device, so that waiting overtime is avoided; when the fact that the session information does not exist in the standby network equipment is determined, the client is requested to close the first socket interface, the server is requested to close the second socket interface, the client and the server can determine that the session is abnormal more quickly, the socket interface is newly built for session, the session is prevented from being reestablished after the session is waited for overtime, the waiting time of application service in the client is shortened, and the efficiency of processing the session abnormity is improved; by receiving the session request message sent by the client through the third socket interface and sending the session request message to the server, the server can establish the fourth socket interface according to the session request message, so that the message between the client and the server can be forwarded through the third socket interface and the fourth socket interface, the session between the client and the server can be recovered more quickly, and the efficiency of processing session abnormity is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, 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 some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a session exception handling method provided in an embodiment of the present application;
fig. 2 is an interaction diagram of forwarding a packet between a client and a server according to an embodiment of the present application;
fig. 3 is a schematic diagram of another interaction for forwarding a packet between a client and a server according to an embodiment of the present application;
FIG. 4 is a schematic flow chart diagram providing sub-steps for requesting a client to close a first socket interface according to an embodiment of the present application;
FIG. 5 is a schematic flow chart diagram of sub-steps of requesting a server to close a second socket interface provided by an embodiment of the present application;
fig. 6 is an interaction diagram of receiving a session request packet sent by a client through a third socket interface according to an embodiment of the present application;
fig. 7 is an interaction diagram of receiving a response packet sent by a server through a fourth socket interface according to an embodiment of the present application;
fig. 8 is a schematic block diagram of a session exception handling apparatus according to an embodiment of the present application;
fig. 9 is a schematic block diagram of a structure of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It is to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
The embodiment of the application provides a session exception handling method and device, computer equipment and a storage medium. The session exception handling method can be applied to the standby network equipment, and when the main network equipment fails and the standby network equipment does not have session information, the client is requested to close the first socket interface and the server is requested to close the second socket interface, so that the client and the server can determine that the session is abnormal more quickly and establish the socket interface for session, the session is prevented from being reestablished after overtime is waited, and the efficiency of handling the session exception is improved.
The main Network device and the standby Network device may be stateful Virtual Network Function (VNF) devices, such as stateful firewalls, load balancing devices, and the like. The servers may be independent servers or server clusters. The client can be an electronic device such as a smart phone, a tablet computer, a notebook computer, a desktop computer and the like.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
As shown in fig. 1, the session exception handling method includes steps S10 to S40.
Step S10, when a master network device corresponding to a client and a server fails, querying whether session information exists in a standby network device, where the client and the server currently perform session communication through a first socket interface of the client and a second socket interface of the server.
It should be noted that, when the main network device corresponding to the client and the server fails, whether the standby network device has session information is queried, and whether the first socket interface and the second socket interface need to be closed may be determined according to a query result.
Referring to fig. 2, fig. 2 is a schematic diagram of interaction of forwarding a message between a client and a server by a main network device according to an embodiment of the present application. In fig. 2, the main network device is used for carrying a service between the client and the server, for example, sending a session message of the client to the server, and sending a response message generated by the server according to the session message to the client. When the main network device carries the service, the session information can be synchronized to the standby network device through the network, so that the standby network device can forward the session message according to the session information when carrying the service. For example, when the main network device fails, the service is automatically switched to the standby network device, and the standby network device carries the service.
Illustratively, the client and the server are currently in session communication via a first socket interface of the client and a second socket interface of the server.
It should be noted that a socket (socket) is used to describe an IP address and a port, and is a handle of a communication chain, which can be used to implement communication between different virtual machines or different computers. In the embodiment of the application, the first socket interface is established when the client communicates with the server and serves as a local identifier at the client; the second socket interface is established when the server and the client communicate, and serves as a local identifier at the server. For example, the client may establish a first socket interface with the server when receiving the session packet of the application service, and the server may also establish a second socket interface with the client. The process of establishing the socket interface may include monitoring, requesting and connection confirming, and the detailed process of establishing the socket interface is not described herein.
In some embodiments, when a main network device corresponding to a client and a server fails, before inquiring whether session information exists in a standby network device, the standby network device may perform session information synchronization with the main network device; if the session information is successfully synchronized, saving the session information; and if the synchronization of the session information fails, determining that the session information is not acquired.
It should be noted that the session information synchronization is used to obtain the session information generated by the host network device according to the first socket interface and the second socket interface.
For example, as shown in fig. 2, when the main network device is operating normally, the main network device may receive a session message sent by the client through the first socket interface, and then send the session message to the second socket interface of the server. Therefore, the main network device can synchronize the session information to the standby network device according to the session information generated by the first socket interface and the second socket interface, so that the session information is not lost, and when the main network device fails, the standby network device can determine the first socket interface and the second socket interface through the session information, and then forward the message between the client and the server through the first socket interface and the second socket interface, so as to avoid waiting overtime.
For example, the primary network device may generate session information based on configuration parameters of the first socket interface and the second socket interface. The configuration parameters may include session protocol, source address, source port, destination address, destination port, and so on. The session Protocol may be a TCP (Transmission Control Protocol), which is a connection-oriented, reliable, and byte-stream-based transport layer communication Protocol.
In the embodiment of the present application, after the session information is generated, the primary network device may synchronize the session information with the standby network device in real time or at regular time. For example, the main network device may send a session information synchronization request to the standby network device, and the standby network device may perform session information synchronization with the main network device according to the session information synchronization request. For another example, the standby network device may periodically or in real-time request session information synchronization with the primary network device.
Illustratively, if the session information is successfully synchronized, the session information is saved; for example, session information may be stored in a local database or local disk, or may be stored in a blockchain. It should be noted that, storing the session information in the blockchain can ensure the privacy and security of the session information.
For example, if the session information synchronization fails, the standby network device determines that the session information is not acquired.
It should be noted that, in the session information synchronization process, due to the abnormal session synchronization module and the jitter of the synchronization network channel, the packet loss, the instantaneous high load of the cluster members, the priority processing of the resources on the forwarding traffic, the lack of resources for session synchronization, and the like, may cause synchronization failure. So that the standby network device does not acquire the session information.
The session information can be timely stored by synchronizing the session information with the main network device, so that the session information is not lost, and the standby network device can realize session switching through the session information when the main network device fails.
In this embodiment, when the main network device is operating normally, the client and the server are currently in session communication through the first socket interface of the client and the second socket interface of the server. When a main network device corresponding to a client and a server fails, whether session information exists in a standby network device needs to be inquired.
In some embodiments, after querying whether session information exists in the network device, the method may further include: when the standby network equipment has session information, determining a first socket interface and a second socket interface according to the session information; and forwarding the session message between the client and the server based on the first socket interface and the second socket interface.
For example, the configuration parameters corresponding to the first socket interface and the configuration parameters corresponding to the second socket interface may be determined according to the session information, and further, the source address, the source port, the destination address, the destination port, and the like corresponding to the first socket interface and the second socket interface may be determined according to the configuration parameters. It is understood that the first socket interface and the second socket interface are a pair of communication connection interfaces in a session, so that the source address of the first socket interface can be the destination address of the second socket interface, and the destination address of the first socket interface can be the source address of the second socket interface.
Referring to fig. 3, fig. 3 is an interaction diagram of forwarding a packet between a client and a server by a standby network device according to an embodiment of the present application. For example, after determining the first socket interface and the second socket interface, the session packet between the client and the server may be forwarded based on the first socket interface and the second socket interface. For example, a session message sent by the client through the first socket interface may be received, and the session message is sent to the second socket interface of the server; and the response message returned by the server through the second socket interface can be received, and the response message is sent to the first socket interface of the client.
The first socket interface and the second socket interface are determined according to the session information, so that the message between the client and the server is forwarded through the first socket interface and the second socket interface, the waiting overtime is avoided, and the performance of the application service is improved.
Step S20, if the session information does not exist in the standby network device, requesting the client to close the first socket interface, and requesting the server to close the second socket interface.
It should be noted that, if the standby network device does not have session information, it may be that when the session information of the standby network device and the session information of the main network device are synchronized, the session information synchronization fails, and thus the standby network device does not acquire the session information.
In the embodiment of the application, when it is determined that the standby network device does not have session information, the client may be requested to close the first socket interface, so that the client can determine that the session is abnormal more quickly, and close the first socket interface, thereby avoiding reestablishing the session after waiting for timeout.
Referring to fig. 4, fig. 4 is a schematic flowchart of sub-steps of requesting a client to close a first socket interface according to an embodiment of the present application, and specifically includes the following steps S201 to S203.
Step S201, obtaining a first message, where the first message is sent to the standby network device after the session of the client and the server is over time.
In the embodiment of the application, when the client sends the session message to the standby network device, the standby network device cannot forward the session message to the server because the standby network device does not have session information, and therefore the standby network device discards the session message. At this time, if the client does not receive the response message within the specified time, the client determines that the session timeout occurs in the current session with the server, and the client will send a message to the standby network device again and continue to wait. And the client side does not determine that the waiting time is overtime until the times of sending the message by the client side are greater than the preset times or the waiting time is greater than the preset time. The preset times and the preset time can be set according to specific conditions, and specific values are not limited herein.
For example, a first message sent by the client after the session timeout with the server may be obtained. The first packet may include quintuple data, as follows:
protocol: TCP, source IP: CIP, source port: 3100, destination IP: SIP, destination port: 80. wherein, the "source IP: CIP, source port: 3100 "source information; "destination IP: SIP, destination port: 80' is destination information. The field CIP indicates the IP address of the client and the field SIP indicates the IP address of the server.
Step S202, according to the first message, generating a first reset message corresponding to the first message.
In some embodiments, generating a first reset packet corresponding to the first packet according to the first packet may include: interchanging the destination information and the source information in the first message to obtain an interchanged message; and adding a preset key value pair field to the exchanged message to obtain a first reset message, wherein the key value pair field is used for indicating that the attribute type of the first reset message is reset.
Illustratively, the destination information in the first message is "destination IP: SIP, destination port: 80 'and the source information is' source IP: CIP, source port: 3100 "; after the destination information and the source information are exchanged, the source information is "source IP: SIP, source port: 80 ", the destination information is" destination IP: CIP, destination port: 3100".
For example, the preset key-value pair field may be "type: RST "for indicating that the message is a reset message. It should be noted that the reset message is used to close the socket interface that is not needed or normal.
For example, the generated first reset message may include: protocol: TCP, type: RST, source IP: SIP, source port: 80, destination IP: CIP, destination port: 3100.
step S203, sending the first reset message to the client, so that the client closes the first socket interface according to the first reset message.
For example, after generating the first reset packet corresponding to the first packet, the first reset packet may be sent to the client. After receiving the first reset message, the client may recognize that the attribute of the first reset message is the reset message, and then close the first socket interface according to the first reset message.
By acquiring a first message sent by a client, a first reset message for closing a socket interface can be generated according to the first message; by sending the first reset message to the client, the client can close the first socket interface according to the first reset message, avoid reestablishing the session after the timeout, shorten the waiting time of the application service in the client, and improve the efficiency of processing the session exception.
In the embodiment of the application, when it is determined that the standby network device does not have session information, the server may be requested to close the second socket interface, so that the server can determine that the session is abnormal more quickly, and close the second socket interface, thereby avoiding waiting overtime.
Referring to fig. 5, fig. 5 is a schematic flowchart illustrating sub-steps of requesting a server to close a second socket interface according to an embodiment of the present application, which may specifically include the following steps S204 to S206.
Step S204, a second message is obtained, wherein the second message is sent to the standby network equipment after the session of the server and the client is overtime.
In this embodiment of the present application, the server may also send a session packet to the standby network device, and the standby network device cannot forward the session packet to the client because the standby network device does not have session information, so that the standby network device may directly discard the session packet. At this time, if the server does not receive the response message within the specified time, the server determines that the session with the client is overtime, and the server will send a message to the standby network device again and continue to wait.
For example, the second message sent by the server after the session timeout with the client may be obtained. Wherein, the second message is as follows:
protocol: TCP, source IP: SIP, source port: 80, destination IP: CIP, destination port: 3100.
step S205, according to the second packet, generating a second reset packet corresponding to the second packet.
It should be noted that the process of generating the second reset packet according to the second packet is similar to the process of generating the first reset packet according to the first packet in the foregoing embodiment.
Illustratively, exchanging the destination information and the source information in the second message to obtain an exchanged message; and adding a preset key value pair field to the exchanged message to obtain a second reset message. For example, the second reset message includes: protocol: TCP, type: RST, source IP: CIP, source port: 3100, destination IP: SIP, destination port: 80.
step S206, the second reset message is sent to the server, so that the server closes the second socket interface according to the second reset message.
It should be noted that, after the second reset message corresponding to the second message is generated, the second reset message may be sent to the server. After receiving the second reset message, the server may identify that the attribute of the second reset message is a reset message, and then close the second socket interface.
The second reset message used for closing the socket interface can be generated according to the second message by acquiring the second message sent by the server, and the server can close the socket interface according to the second reset message by sending the second reset message to the server, so that the situation that the session is reestablished after the waiting time is out is avoided.
Step S30, receiving a session request packet sent by the client through a third socket interface, where the third socket interface is established when the client receives the session request packet after closing the first socket interface.
In this embodiment of the present application, after requesting the client to close the first socket interface, the standby network device may further receive a session request packet sent by the client through the third socket interface.
It should be noted that after the client closes the first socket interface, when receiving a session request packet sent by an application service in the client, the client needs to reestablish a socket interface because the first socket interface is already closed. Illustratively, the client may create a third socket interface according to the session request packet; the configuration parameters of the third socket interface are as follows: protocol: TCP, source IP: CIP, source port: 3101, destination IP: SIP, destination port: 80.
referring to fig. 6, fig. 6 is an interaction diagram of receiving a session request packet sent by a client through a third socket interface according to an embodiment of the present application. As shown in fig. 6, after establishing the third socket interface, the client may send the session request packet to the standby network device through the third socket interface, so that the standby network device forwards the session request packet to the server.
By receiving the session request message sent by the client through the third socket interface, the session request message can be subsequently sent to the server.
Step S40, sending the session request packet to the server, so that the server establishes a fourth socket interface according to the session request packet, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
It should be noted that, after receiving the session request message, the server may establish a fourth socket interface corresponding to the third socket interface according to the session request message; after the fourth socket interface is established, the server may also generate a response message according to the session request message, and a specific generation process is not limited herein.
Illustratively, the configuration parameters of the fourth socket interface are: protocol: TCP, source IP: SIP, source port: 80, destination IP: CIP, destination port: 3101.
in this embodiment of the present application, after sending the session request packet to the server, the method may further include: receiving a response message sent by the server through the fourth socket interface, wherein the response message is generated by the server according to the session request message; and sending the response message to the client.
Referring to fig. 7, fig. 7 is an interaction diagram of receiving a response packet sent by a server through a fourth socket interface according to an embodiment of the present application. As shown in fig. 7, the standby network device may receive a response message sent by the server through the fourth socket interface, determine the third socket interface of the client according to the destination information in the response message, and then send the response message to the third socket interface. It can be understood that, since the client communicates with the outside through the third socket interface, the response message is sent to the third socket interface, and the client can obtain the response message through the third socket interface.
In some embodiments, when the client and the server perform session communication with the fourth socket interface through the third socket interface, the standby network device may generate session information according to the third socket interface and the fourth socket interface, and synchronize the session information to the host network device; after the main network device recovers normal operation, the third socket interface and the fourth socket interface can be determined through the session information, and the session message between the client and the server is forwarded based on the third socket interface and the fourth socket interface.
By sending the session request message to the server, the server can establish the fourth socket interface according to the session request message, so that the message between the client and the server can be forwarded through the third socket interface and the fourth socket interface, the session between the client and the server can be recovered more quickly, and the efficiency of processing session exception is improved.
In the method for processing session exception provided in the foregoing embodiment, when a failure occurs in a main network device corresponding to a client and a server, whether session information exists in a standby network device is queried, and whether a first socket interface and a second socket interface need to be closed can be determined according to a query result; the session information is synchronized with the main network equipment, so that the session information can be timely stored, the session information is not lost, and the standby network equipment can realize session switching through the session information when the main network equipment fails; the first socket interface and the second socket interface are determined according to the session information, so that the message between the client and the server is forwarded through the first socket interface and the second socket interface, the waiting overtime is avoided, and the performance of the application service is improved; when the fact that the session information does not exist in the standby network equipment is determined, the client is requested to close the first socket interface, so that the client can determine that the session is abnormal more quickly, the first socket interface is closed, and the session is prevented from being reestablished after the session is waited for overtime; by acquiring the first message sent by the client, the first reset message used for closing the socket interface can be generated according to the first message, and the first reset message is sent to the client, so that the client can close the first socket interface according to the first reset message, the session is prevented from being reestablished after the timeout, the waiting time of the application service in the client is shortened, and the efficiency of processing the session abnormity is improved; by acquiring a second message sent by the server, a second reset message for closing the socket interface can be generated according to the second message, and the second reset message is sent to the server, so that the server can close the socket interface according to the second reset message, and the phenomenon that the session is reestablished after the timeout occurs is avoided; by receiving the session request message sent by the client through the third socket interface, the session request message can be sent to the server subsequently; by sending the session request message to the server, the server can establish the fourth socket interface according to the session request message, so that the message between the client and the server can be forwarded through the third socket interface and the fourth socket interface, the session between the client and the server can be recovered more quickly, and the efficiency of processing session exception is improved.
Referring to fig. 8, fig. 8 is a schematic block diagram of a session exception handling apparatus 1000 according to an embodiment of the present application, which is configured to execute the session exception handling method described above. The session exception handling device may be configured to the standby network device.
As shown in fig. 8, the session exception handling apparatus 1000 includes: a session information query module 1001, a request close interface module 1002, a message receiving module 1003 and a message sending module 1004.
A session information query module 1001, configured to query whether session information exists in a standby network device when a master network device corresponding to a client and a server fails, where the client and the server currently perform session communication through a first socket interface of the client and a second socket interface of the server;
a request close interface module 1002, configured to request the client to close the first socket interface and request the server to close the second socket interface if the session information does not exist in the standby network device;
a message receiving module 1003, configured to receive a session request message sent by the client through a third socket interface, where the third socket interface is established when the client receives the session request message after closing the first socket interface;
a message sending module 1004, configured to send the session request message to the server, so that the server establishes a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
It should be noted that, as will be clear to those skilled in the art, for convenience and brevity of description, the specific working processes of the apparatus and the modules described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The apparatus described above may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 9.
Referring to fig. 9, fig. 9 is a schematic block diagram of a computer device according to an embodiment of the present disclosure. The computer device may be a stateful virtual network enabled device.
Referring to fig. 9, the computer device includes a processor and a memory connected by a system bus, wherein the memory may include a nonvolatile storage medium and an internal memory.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for running a computer program in the non-volatile storage medium, and the computer program, when executed by the processor, causes the processor to perform any one of the session exception handling methods.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
when main network equipment corresponding to a client and a server fails, inquiring whether session information exists in standby network equipment or not, wherein the client and the server carry out session communication currently through a first socket interface of the client and a second socket interface of the server; if the session information does not exist in the standby network equipment, requesting the client to close the first socket interface and requesting the server to close the second socket interface; receiving a session request message sent by the client through a third socket interface, wherein the third socket interface is established when the client receives the session request message after closing the first socket interface; and sending the session request message to the server so that the server establishes a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
In one embodiment, before the querying whether session information exists in the standby network device when a primary network device corresponding to the server and the client fail, the processor is further configured to:
synchronizing session information with the primary network device; if the session information is successfully synchronized, saving the session information; and if the synchronization of the session information fails, determining that the session information is not acquired.
In one embodiment, the processor, when implementing the request to close the first socket interface, is configured to implement:
acquiring a first message, wherein the first message is sent to the standby network equipment after the session of the client and the server is overtime; generating a first reset message corresponding to the first message according to the first message; and sending the first reset message to the client so that the client closes the first socket interface according to the first reset message.
In an embodiment, the processor generates, according to the first packet, a first reset packet corresponding to the first packet, so as to implement:
interchanging the destination information and the source information in the first message to obtain an interchanged message; and adding a preset key value pair field to the exchanged message to obtain the first reset message, wherein the key value pair field is used for indicating that the attribute type of the first reset message is reset.
In one embodiment, the processor is further configured to, in response to the request from the server to close the second socket interface, implement:
acquiring a second message, wherein the second message is sent to the standby network equipment after the session of the server and the client is overtime; generating a second reset message corresponding to the second message according to the second message; and sending the second reset message to the server so that the server closes the second socket interface according to the second reset message.
In one embodiment, after the querying whether session information exists in the standby network device, the processor is further configured to:
when the session information exists in the standby network equipment, determining the first socket interface and the second socket interface according to the session information; and forwarding the session message between the client and the server based on the first socket interface and the second socket interface.
In one embodiment, after the sending of the session request packet to the server is implemented, the processor is further configured to implement:
receiving a response message sent by the server through the fourth socket interface, wherein the response message is generated by the server according to the session request message; and sending the response message to the client.
The embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes program instructions, and the processor executes the program instructions to implement any session exception handling method provided in the embodiment of the present application.
The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital Card (SD Card), a Flash memory Card (Flash Card), and the like provided on the computer device.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (10)
1. A method for processing session exception, comprising:
when main network equipment corresponding to a client and a server fails, inquiring whether session information exists in standby network equipment or not, wherein the client and the server carry out session communication currently through a first socket interface of the client and a second socket interface of the server;
if the session information does not exist in the standby network equipment, requesting the client to close the first socket interface and requesting the server to close the second socket interface;
receiving a session request message sent by the client through a third socket interface, wherein the third socket interface is established when the client receives the session request message after closing the first socket interface;
and sending the session request message to the server so that the server establishes a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
2. The method according to claim 1, wherein before querying whether session information exists in the standby network device when a primary network device corresponding to the client and the server fails, the method further comprises:
synchronizing session information with the primary network device;
if the session information is successfully synchronized, saving the session information;
and if the synchronization of the session information fails, determining that the session information is not acquired.
3. The method according to claim 1, wherein the requesting the client to close the first socket interface comprises:
acquiring a first message, wherein the first message is sent to the standby network equipment after the session of the client and the server is overtime;
generating a first reset message corresponding to the first message according to the first message;
and sending the first reset message to the client so that the client closes the first socket interface according to the first reset message.
4. The method according to claim 3, wherein the generating a first reset packet corresponding to the first packet according to the first packet includes:
interchanging the destination information and the source information in the first message to obtain an interchanged message;
and adding a preset key value pair field to the exchanged message to obtain the first reset message, wherein the key value pair field is used for indicating that the attribute type of the first reset message is reset.
5. The method according to claim 1, wherein the requesting the server to close the second socket interface comprises:
acquiring a second message, wherein the second message is sent to the standby network equipment after the session of the server and the client is overtime;
generating a second reset message corresponding to the second message according to the second message;
and sending the second reset message to the server so that the server closes the second socket interface according to the second reset message.
6. The method for processing session exception according to claim 1, wherein after querying whether the session information exists in the standby network device, the method further comprises:
when the session information exists in the standby network equipment, determining the first socket interface and the second socket interface according to the session information;
and forwarding the session message between the client and the server based on the first socket interface and the second socket interface.
7. The method according to any one of claims 1 to 5, wherein after the sending the session request packet to the server, the method further includes:
receiving a response message sent by the server through the fourth socket interface, wherein the response message is generated by the server according to the session request message;
and sending the response message to the client.
8. A session exception handling apparatus, comprising:
the session information query module is used for querying whether session information exists in the standby network equipment or not when main network equipment corresponding to a client and a server fails, wherein the client and the server carry out session communication currently through a first socket interface of the client and a second socket interface of the server;
a request closing interface module, configured to request the client to close the first socket interface and request the server to close the second socket interface if the session information does not exist in the standby network device;
a message receiving module, configured to receive a session request message sent by the client through a third socket interface, where the third socket interface is established when the client receives the session request message after closing the first socket interface;
and the message sending module is used for sending the session request message to the server so as to enable the server to establish a fourth socket interface according to the session request message, and the client and the server perform session communication with the fourth socket interface through the third socket interface.
9. A computer device, wherein the computer device comprises a memory and a processor;
the memory for storing a computer program;
the processor, configured to execute the computer program and to implement the session exception handling method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, causes the processor to implement the session exception handling method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110343633.2A CN112929225B (en) | 2021-03-30 | 2021-03-30 | Session exception handling method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110343633.2A CN112929225B (en) | 2021-03-30 | 2021-03-30 | Session exception handling method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112929225A true CN112929225A (en) | 2021-06-08 |
CN112929225B CN112929225B (en) | 2022-09-30 |
Family
ID=76176723
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110343633.2A Active CN112929225B (en) | 2021-03-30 | 2021-03-30 | Session exception handling method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112929225B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113746821A (en) * | 2021-08-24 | 2021-12-03 | 深圳Tcl新技术有限公司 | Intelligent device control method and device, storage medium and electronic device |
CN115334139A (en) * | 2022-06-24 | 2022-11-11 | 百果园技术(新加坡)有限公司 | Communication connection control method and device |
CN116668412A (en) * | 2023-06-02 | 2023-08-29 | 北京首都在线科技股份有限公司 | Communication interaction method and device, electronic equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114929A (en) * | 2006-07-24 | 2008-01-30 | 中兴通讯股份有限公司 | Method of establishing interlinkage for preventing communication abnormality between network management terminal and equipment |
US20130054822A1 (en) * | 2011-08-30 | 2013-02-28 | Rajiv P. Mordani | Failover Data Replication with Colocation of Session State Data |
CN107547618A (en) * | 2017-06-09 | 2018-01-05 | 新华三技术有限公司 | A kind of session teardown method and apparatus |
CN110247806A (en) * | 2019-06-25 | 2019-09-17 | 杭州迪普科技股份有限公司 | Session failure processing method, device, electronic equipment |
CN111327639A (en) * | 2020-03-19 | 2020-06-23 | 刘奇峰 | Socket communication method and device |
-
2021
- 2021-03-30 CN CN202110343633.2A patent/CN112929225B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114929A (en) * | 2006-07-24 | 2008-01-30 | 中兴通讯股份有限公司 | Method of establishing interlinkage for preventing communication abnormality between network management terminal and equipment |
US20130054822A1 (en) * | 2011-08-30 | 2013-02-28 | Rajiv P. Mordani | Failover Data Replication with Colocation of Session State Data |
CN107547618A (en) * | 2017-06-09 | 2018-01-05 | 新华三技术有限公司 | A kind of session teardown method and apparatus |
CN110247806A (en) * | 2019-06-25 | 2019-09-17 | 杭州迪普科技股份有限公司 | Session failure processing method, device, electronic equipment |
CN111327639A (en) * | 2020-03-19 | 2020-06-23 | 刘奇峰 | Socket communication method and device |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113746821A (en) * | 2021-08-24 | 2021-12-03 | 深圳Tcl新技术有限公司 | Intelligent device control method and device, storage medium and electronic device |
CN113746821B (en) * | 2021-08-24 | 2023-06-27 | 深圳Tcl新技术有限公司 | Intelligent device control method and device, storage medium and electronic device |
CN115334139A (en) * | 2022-06-24 | 2022-11-11 | 百果园技术(新加坡)有限公司 | Communication connection control method and device |
CN115334139B (en) * | 2022-06-24 | 2023-12-26 | 百果园技术(新加坡)有限公司 | Communication connection control method and device |
CN116668412A (en) * | 2023-06-02 | 2023-08-29 | 北京首都在线科技股份有限公司 | Communication interaction method and device, electronic equipment and storage medium |
CN116668412B (en) * | 2023-06-02 | 2024-02-13 | 北京首都在线科技股份有限公司 | Communication interaction method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112929225B (en) | 2022-09-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112929225B (en) | Session exception handling method and device, computer equipment and storage medium | |
US10983880B2 (en) | Role designation in a high availability node | |
WO2021121370A1 (en) | Message loss detection method and apparatus for message queue | |
CN108712332B (en) | Communication method, system and device | |
US12028442B2 (en) | Accessing security hardware keys | |
CN111459749B (en) | Prometheus-based private cloud monitoring method and device, computer equipment and storage medium | |
US11902130B2 (en) | Data packet loss detection | |
CN109960634B (en) | Application program monitoring method, device and system | |
WO2019100598A1 (en) | Transaction processing method and device, computer equipment, and storage medium | |
WO2019075773A1 (en) | Data processing method and apparatus, computer device and storage medium | |
US8566847B2 (en) | Out-of-band host management via a management controller | |
US9621412B2 (en) | Method for guaranteeing service continuity in a telecommunication network and system thereof | |
WO2019090997A1 (en) | Data acquisition method and device, computer device and storage medium | |
WO2024016624A1 (en) | Multi-cluster access method and system | |
US20220345371A1 (en) | Control configuration for a plurality of endpoint devices | |
WO2021000622A1 (en) | Database access method and apparatus, computing device and computer program product | |
WO2016101409A1 (en) | Data switching method, device and system | |
CN113507431A (en) | Message management method, device, equipment and machine readable storage medium | |
CN111431951B (en) | Data processing method, node equipment, system and storage medium | |
US11595471B1 (en) | Method and system for electing a master in a cloud based distributed system using a serverless framework | |
CN111416851A (en) | Method for session synchronization among multiple load balancers and load balancer | |
CN103858384A (en) | System and method for cloud-based implementation of control of focused overload of network element (COFO-NE) | |
US10270654B2 (en) | System for increasing computing efficiency of communication between applications running on networked machines | |
CN115767786A (en) | Multi-cluster communication method and device, electronic equipment and storage medium | |
CN107145408A (en) | A kind of method and system for realizing active and standby clustered deploy(ment) |
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 |