Device session maintenance method, device, apparatus and medium of internet of things platform
By combining LVS load balancing and process dictionary, the database pressure problem caused by the massive number of connected devices in the IoT platform is solved, and efficient maintenance and performance improvement of device sessions are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- E SURFING IOT CO LTD
- Filing Date
- 2022-12-29
- Publication Date
- 2026-05-29
AI Technical Summary
When a large number of NB-IoT devices are connected to an IoT platform, the database memory pressure and read/write pressure increase sharply, access performance and efficiency decrease, and the platform's robustness is reduced.
By using LVS's IP load balancing to connect devices to the access node, establishing socket sessions, and storing device information using a process dictionary to reduce database operations, and by using RPC to update key information in the routing node, seamless migration and recovery of device sessions can be achieved.
It reduces database storage and read/write pressure, improves access performance and efficiency, maintains platform robustness, and adapts to massive device access.
Smart Images

Figure CN115968011B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) platform technology, and in particular to a method, apparatus, device, and medium for maintaining device sessions on an IoT platform. Background Technology
[0002] NB-IoT is widely used in the Internet of Things (IoT) field due to its wide coverage, high connectivity, low data rate, low cost, and low power consumption. Most NB-IoT devices are based on the UDP protocol. Due to the linkless nature of UDP, long-term sessions cannot be maintained. With massive access volumes, the platform needs to frequently operate the database to perform CRUD operations to ensure the accuracy of device information, leading to a sharp increase in database memory and access pressure, and a corresponding reduction in efficiency and performance. Summary of the Invention
[0003] This invention provides a method, apparatus, device, and medium for maintaining device sessions on an Internet of Things (IoT) platform, aiming to solve the problems of increased database memory and read / write pressure, decreased access performance and efficiency, and reduced platform robustness in existing IoT platforms when a large number of devices are connected.
[0004] In a first aspect, embodiments of the present invention provide a device session maintenance method for an Internet of Things (IoT) platform, comprising: connecting a plurality of devices to be accessed to an access node through IP load balancing of LVS, and establishing a socket session between the access node and the devices to be accessed; storing device information of the devices to be accessed in the process dictionary of the access node, and storing key information in the process dictionary in a routing node; receiving uplink packets from the devices to be accessed and updating the process dictionary in the access node according to the uplink packets, and updating the routing node according to the key information in the updated process dictionary.
[0005] Secondly, embodiments of the present invention also provide a device session maintenance apparatus for an Internet of Things (IoT) platform, comprising: a session establishment unit, configured to connect a plurality of devices to be accessed to an access node through IP load balancing of LVS, and establish a socket session between the access node and the devices to be accessed; a storage unit, configured to store device information of the devices to be accessed in the process dictionary of the access node, and store key information in the process dictionary in a routing node; and a message interaction unit, configured to receive uplink messages from the devices to be accessed and update the process dictionary in the access node according to the uplink messages, and update the routing node according to the key information in the updated process dictionary.
[0006] Thirdly, embodiments of the present invention also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.
[0007] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, can implement the method described in the first aspect.
[0008] This invention provides a method, apparatus, device, and medium for maintaining device sessions on an IoT platform. The method includes: connecting several devices to an access node via LVS IP load balancing and establishing socket sessions between the access node and the devices; storing device information of the devices in the process dictionary of the access node and storing key information from the process dictionary in a routing node; receiving uplink packets from the devices and updating the process dictionary in the access node based on the uplink packets, and updating the routing node based on the key information in the updated process dictionary. This invention's solution utilizes LVS's DR mode to implement long-connection session processes for the devices, reducing the number of interactions caused by changes in device information and data. Furthermore, using a process dictionary for storage not only reduces database storage and read / write pressure but also provides better access performance and efficiency than database read / write, improving platform access efficiency and performance. Attached Figure Description
[0009] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 This is a schematic diagram illustrating an application scenario of the device session maintenance method for an IoT platform provided in an embodiment of the present invention.
[0011] Figure 2 A flowchart illustrating the device session maintenance method for an IoT platform provided in an embodiment of the present invention;
[0012] Figure 3 A schematic diagram of the message interaction process of the device session maintenance method of the Internet of Things platform provided in the embodiments of the present invention;
[0013] Figure 4A flowchart illustrating a device session maintenance method for an IoT platform provided in another embodiment of the present invention;
[0014] Figure 5 A schematic diagram illustrating the access node change process of the device session maintenance method for the IoT platform provided in this embodiment of the invention;
[0015] Figure 6 A schematic block diagram of a device session maintenance apparatus for an Internet of Things (IoT) platform provided in an embodiment of the present invention;
[0016] Figure 7 A schematic block diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0019] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0020] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0021] Please see Figure 1 , Figure 1This is a schematic diagram illustrating an application scenario of the device session maintenance method for an IoT platform provided in this embodiment of the invention. The application scenario includes NB-IoT devices (i.e., NB devices in the diagram), LVS, access nodes, and routing nodes. The NB-IoT devices represent the massive number of devices to be connected in this embodiment, while the access nodes and routing nodes are nodes deployed by the IoT platform, which provides access services. Traditional massive access to IoT devices typically employs database solutions, leading to frequent database operations and a sharp increase in database storage and access pressure. Furthermore, due to the linkless nature of NB-IoT devices, long-term sessions cannot be maintained, resulting in even more frequent database operations. Therefore, this embodiment of the invention proposes a device session maintenance method for an IoT platform that overcomes the linkless nature of UDP, maintains NB-IoT device socket sessions, stores device information in the session, and enables the storage, addition, deletion, modification, and querying of session information; and allows for seamless migration and recovery of device sessions when access nodes change. Thus, it is suitable for the massive access and management of NB-IoT devices, achieving session maintenance for NB-IoT devices while solving the database memory and access pressure problems. Moreover, it can be extended to devices in other network standards or other fields. This embodiment supports massive access for NB-IoT type devices on the Internet of Things platform, including but not limited to: LWM2M protocol, CoAP protocol, and UDP protocol.
[0022] The following provides a detailed description of the device session maintenance method for the IoT platform. For example... Figure 2 As shown, the method includes the following steps S110-S130.
[0023] S110. Several devices to be accessed are connected to the access node through LVS IP load balancing, and a socket session is established between the access node and the devices to be accessed.
[0024] In this embodiment, LVS is short for Linux Virtual Server, meaning Linux virtual server. It is a virtual server cluster system that uses clustering technology and the Linux operating system to implement a high-performance, highly available server. It has excellent scalability, reliability, and manageability, thereby achieving optimal service performance at a low cost. Cluster load balancing techniques can distribute load based on IP, port, content, etc., with IP-based load balancing being the most efficient. Common IP-based load balancing modes include Network Address Translation (NAT), IP Tunneling (TUN), and Direct Routing (DR). This embodiment uses DR mode to achieve load balancing, ensuring a dynamic balance in the number of devices on each access node. Access nodes are stateless and independent, allowing for massive access by horizontally scaling the number of nodes. A socket is a two-way communication connection between two applications to exchange data. The connection segment is called a socket. Implementing a socket connection requires at least two sockets: one running on the server side (jack) and one running on the client side (plug). A socket describes an IP address and port and is a handle to a communication link. Applications use sockets to send requests to or respond to network requests. Therefore, a socket is neither a program nor a protocol, but rather a set of abstract API interfaces provided by the operating system to the communication layer. This embodiment uses sockets to establish a process session between the device to be connected and the access node; all uplink and downlink packets are transmitted through this process session.
[0025] In a specific implementation, step S110 includes the following steps: establishing a link with the device to be accessed through LVS DR mode and setting a keep-alive time; obtaining the IP and port of the device to be accessed to listen to the socket of the device to be accessed; and establishing a socket session based on the socket and unique identifier of the device to be accessed.
[0026] Specifically, the device to be connected establishes a link with the access node through LVS's DR mode. By setting a keep-alive time, the link between LVS and the access node can be maintained for a certain period of time as long as the IP address of the device to be connected does not change. Therefore, the access node can be considered to have a long-lived connection with the device to be connected. Due to its high performance and complete information preservation, LVS's DR mode allows the access node to directly obtain the source IP address and port of the device to be connected, implement listening socket, and establish a process session based on the protocol and unique identifier of the device to be connected (e.g., IMEI International Mobile Equipment Identity). Subsequent uplink and downlink data interactions of the device to be connected are all executed in this process. Therefore, each device process is independent and does not affect the others.
[0027] In another embodiment, the keepalive time is dynamically adjusted based on the number of devices to be connected. Specifically, the keepalive time, or keepalive_time, is used to determine whether the other party is still maintaining a connection and whether the connection is healthy and capable of communication when the two parties have not communicated for a long time. The keepalive time works as follows: if the connection is inactive for a period of time (keepalive time), the end that enabled the keepalive function will send a keepalive probe message to the other end. If the other end is alive and the connection is valid, the other end will receive the probe message and respond. At this time, if the sending end receives a response message, it proves that the connection is normal, and the keepalive time counter can be reset. If no response message is received, it means that the connection is abnormal. In this embodiment, the keepalive time is dynamically adjusted rather than a fixed value. The specific dynamic adjustment is based on the number of devices to be connected. For example, when the number of devices to be connected exceeds a certain threshold, the keepalive time can be shortened to release more access nodes, thereby providing access for the devices to be connected and improving the performance of massive access.
[0028] S120. Store the device information of the device to be accessed in the process dictionary of the access node, and store the key information in the process dictionary in the routing node.
[0029] In this embodiment, the process dictionary is a private data storage, a series of key-value associative arrays, where one key corresponds to one value. The data in the process dictionary is private to the process it resides in; it cannot be directly accessed across processes. Furthermore, the process dictionary data is reclaimed when the process is destroyed. The advantages of the process dictionary are its faster access speed compared to a database and the feature of deleting the process dictionary when the process is destroyed. This embodiment uses a process dictionary in conjunction with process sessions. The process dictionary stores information within the session, and useless process dictionary data is deleted when the session process ends. This significantly reduces database storage and read / write pressure, while the access performance and efficiency of the process dictionary are far superior to database read / write. The device information of the device to be connected includes the information carried by the NB device itself and the device attributes required for NB device registration on the IoT platform. Information content includes, for example, device protocol, device IMEI, source IP / port, and device lifecycle; device attributes include, for example, product ID, data format, and power-saving mode. All this device information can be stored in the access node device process dictionary. Key information is a portion of the device information, such as device IMEI, source IP / port, and access node information. The key information is mainly used to identify the device to be connected. The key information is stored in the routing node. Because the session process of the access node may be released at any time, the process dictionary in the access node will be destroyed. Thus, the device information of the device to be connected will also be destroyed. In order not to lose this destroyed key information, this embodiment uses the routing node to back up this key information. When the device to be connected reconnects to another access node, it can be restored by using the key information of the device to be connected backed up in the routing node, thereby realizing seamless session migration and recovery.
[0030] In one embodiment, such as Figure 3 As shown, before step S130, the following steps are included: receiving the login message of the device to be accessed; initializing the process dictionary according to the login message; and storing the key information in the process dictionary into the routing node to initialize the key information.
[0031] Specifically, the message exchange process begins with the device to be accessed sending a login message to the access node, indicating that it has logged into the platform. After the access device successfully logs into the platform, the first step is to initialize the process dictionary of the device to be accessed, that is, to initialize the process dictionary of the device to be accessed (i.e., the process dictionary of the device to be accessed). Figure 3The device information (NBDevice) is initially stored in the process dictionary, including device protocol, device IMEI, source IP / port, device lifecycle, product ID, data format, and power-saving mode. As defined earlier, the process dictionary is a series of key-value pairs. For example, the device IMEI can be used as the key and other information as the value to establish a relationship; the source IP can also be used as the key and other information as the value. Other combinations are also possible and are not limited here. Furthermore, key information needs to be initialized, meaning the crucial information used to identify the device to be connected (such as device IMEI and source IP / port) is initially backed up and stored in the routing node. Subsequent uplink and downlink interactions between the device to be connected and the platform only require adding, deleting, modifying, and querying the process dictionary, reducing database storage and read / write pressure while improving read / write efficiency and performance.
[0032] S130. Receive the uplink message from the device to be accessed and update the process dictionary in the access node according to the uplink message, and update the routing node according to the key information in the updated process dictionary.
[0033] Continue to refer to Figure 3In this embodiment, uplink messages typically contain data collected by the NB device, such as water consumption data from a water meter or electricity consumption data from an electricity meter, and carry device information. Downlink messages return service messages to the NB device, such as billing results or recharge results. Both uplink and downlink messages interact with the NB device through the access node in the session process. The process dictionary in the access node is updated based on the content of the uplink and downlink messages, specifically through adding, deleting, modifying, and querying information. For example, to add new information, the new information is used as the value, and a new association is established with the primary key in the process dictionary; similarly, to delete information, the corresponding value of that information is deleted. After updating the process dictionary, since critical information may also be modified, the critical information backed up in the routing node also needs to be updated synchronously. For example, if the source IP changes, the IP of the device to be accessed in the routing node is also updated synchronously; similarly, if the access node changes, the corresponding node in the routing node is updated accordingly. It should be noted that in this embodiment, when updating critical information, the critical information in the process dictionary (such as device IMEI, source IP / port, access node information, etc.) is compressed and then RPC-sent to the routing node for backup storage or update. The compressed critical information data is smaller and easier to transmit. RPC stands for Remote Procedure Call Protocol, which is built on top of sockets. A main program running on one machine can call a subroutine prepared on another machine, similar to LPC (Local Procedure Call). That is, if there are two servers A and B, and an application deployed on server A wants to call a function / method provided by the application on server B, it cannot be called directly because they are not in the same memory space. It needs to express the semantics of the call and convey the call data through the network. The RPC protocol assumes the existence of certain transport protocols, such as TCP or UDP, to carry information data between communicating programs. In the OSI network communication model, RPC crosses the transport layer and the application layer, without requiring knowledge of the underlying network technology protocols. RPC makes it easier to develop applications, including network-distributed multi-program applications. In other words, RPC makes inter-service calls simple, direct, decoupled, and efficient. By using RPC to realize data transmission between access nodes and routing nodes, there is no need to care about the underlying communication details and calling process. The code is simple, flexible, and efficient.
[0034] In one embodiment, continue to refer to Figure 3 After step S130, the following steps are included: receiving the logout message of the device to be accessed; deleting the process dictionary; and deleting the key information from the routing node via RPC.
[0035] Specifically, if a device to be connected needs to disconnect from the access node, it first needs to send a logout message to the access node, informing the access node that it needs to disconnect. The access node then deletes the process dictionary containing information about the device to be connected, freeing up storage space and connection resources. Furthermore, it also needs to delete critical information about the device to be connected that was previously backed up in the routing node, freeing up storage space and reducing storage pressure on the routing node. The deletion of the process dictionary is performed via RPC, the specific technical advantages of which have been explained earlier and will not be repeated here. After the above logout message and two deletion processes, the process session between the device to be connected and the access node is severed, thereby freeing up more connection resources to facilitate the connection of other devices.
[0036] In one embodiment, the data is forwarded to another access node via LVS's DR mode.
[0037] Specifically, DR mode (Virtual Server via Direct Routing) forwards requests to the real server by rewriting the target MAC address of the request packet. The real server then directly returns the processing result to the client user. Like TUN mode, DR mode significantly improves the scalability of the cluster system. Furthermore, DR mode eliminates the overhead of IP tunneling, and it's not necessary for the real servers in the cluster to support IP tunneling protocols. However, it requires both the load balancer (LB) and the real server (RS) to have a network interface card connected to the same physical network segment and to be in the same local area network (LAN). DR mode is a commonly used mode on the Internet. It should be noted that the working principle and workflow of LVS's DR mode are well-known to those skilled in the art, and for the sake of brevity, they will not be elaborated upon here. However, it can be understood that in DR mode, uplink data from the NB device is directly transmitted through LVS to another access node, while downlink data is directly returned to the device from the access node, which inherently improves the performance of massive access to a certain extent. When the access node changes, its corresponding process session will be disconnected, and the session needs to be migrated to the new access node. The specific operation is as follows:
[0038] In one embodiment, reference is made to Figure 4 The device session maintenance method of the IoT platform further includes steps S140-S180.
[0039] S140. If the access node changes, switch to the changed access node to receive the uplink message of the device to be accessed.
[0040] S150. Query the routing node to see if the same identity information exists based on the identity information of the device to be accessed;
[0041] S160. If the same identity information exists, restore and update the process dictionary of the changed access node according to the uplink message and the key information returned by the routing node.
[0042] S170. Delete the process dictionary in the access node before the change via RPC;
[0043] S180. Update the key information in the updated process dictionary to the routing node.
[0044] In this embodiment, refer to Figure 5 When an access node changes (for ease of description, the previous access node will be referred to as the original access node, and the new access node as the new access node), the new access node receives uplink packets from the devices to be accessed. Upon receiving the uplink packets, the routing node can identify the device by recognizing the identity information of the device, such as its IMEI and source IP / port. The routing node itself has backups of the key information of the device to be accessed, including its identity information, namely the aforementioned IMEI and source IP / port. Therefore, it only needs to match the IMEI and source IP / port carried in the uplink packets with the key information in the routing node. If a match is found, indicating the presence of the same IMEI and source IP / port in the routing node, the routing node can retrieve the previously backed-up key information of the device to be accessed. After obtaining the key information of the device to be connected, this key information is restored to the process dictionary of the new access node. Then, combined with the uplink packets received by the new node, the process dictionary is updated again. Finally, the key information of the device to be connected in the updated process dictionary is backed up to the routing node for updating again, thus completing the data interaction operation of changing the access node. In addition, the new access node also needs to delete the process dictionary in the original access node via RPC to release storage resources. Specifically, when the original access node queries the routing node to see if the same identity information exists, the routing node also returns the information of the original access node in the key information to the new access node. In this way, the new access node can know which node the original access node is, and then delete the process dictionary of the original access node accordingly. Thus, the above series of steps completes the processing of changing the access node. Even if the access node changes, by restoring the key information backed up before, the original data can be preserved and not destroyed, realizing seamless migration and recovery of sessions. The new process session on the new access node can continue to complete the device service interaction until the device goes offline or another node switch occurs.
[0045] Figure 6 This is a schematic block diagram of a device session maintenance device 200 for an Internet of Things (IoT) platform provided in an embodiment of the present invention. Figure 6 As shown, corresponding to the device session maintenance method for the above-described IoT platform, the present invention also provides a device session maintenance apparatus 200 for an IoT platform. This device session maintenance apparatus 200 includes a unit for executing the above-described device session maintenance method for the IoT platform, and the apparatus can be configured in the IoT platform. Specifically, please refer to... Figure 6 The device session maintenance device 200 of the Internet of Things platform includes: a session establishment unit 201, a storage unit 202, and a message interaction unit 203.
[0046] The session establishment unit 201 is used to connect several devices to the access node through LVS IP load balancing and establish a socket session between the access node and the devices to be accessed; the storage unit 202 is used to store the device information of the devices to be accessed in the process dictionary of the access node and store the key information in the process dictionary in the routing node; the message interaction unit 203 is used to receive the uplink message of the devices to be accessed and update the process dictionary in the access node according to the uplink message, and update the routing node according to the key information in the updated process dictionary.
[0047] In one embodiment, the device session maintenance device 200 of the Internet of Things platform includes: a switching unit, a recovery unit, a deletion unit, and an update unit.
[0048] The system includes: a switching unit for switching to the new access node to receive uplink packets from the device to be accessed if the access node changes; a query unit for querying the routing node to see if the same identity information exists based on the identity information of the device to be accessed; a recovery unit for restoring and updating the process dictionary of the new access node based on the uplink packets and the key information returned by the routing node if the same identity information exists; a deletion unit for deleting the process dictionary of the access node before the change via RPC; and an update unit for updating the key information in the updated process dictionary to the routing node.
[0049] In one embodiment, the device session maintenance device 200 of the Internet of Things platform further includes a load balancing unit.
[0050] The load balancing unit is used to forward data to another access node via LVS's DR mode.
[0051] In one embodiment, the session establishment unit 201 includes: a link establishment unit, a listening unit, and an establishment subunit.
[0052] The link establishment unit is used to establish a link with the device to be accessed through LVS DR mode and set the keep-alive time; the listening unit is used to obtain the IP and port of the device to be accessed to listen to the socket of the device to be accessed; and the establishment sub-unit is used to establish a socket session based on the socket and unique identifier of the device to be accessed.
[0053] In one embodiment, the device session maintenance device 200 of the Internet of Things platform further includes a dynamic adjustment unit.
[0054] The dynamic adjustment unit is used to dynamically adjust the keep-alive time based on the number of devices to be connected.
[0055] In one embodiment, the message interaction unit 203 further includes: a login unit, a first initialization unit, and a second initialization unit.
[0056] The system includes a login unit for receiving a login message from the device to be accessed; a first initialization unit for initializing the process dictionary based on the login message; and a second initialization unit for storing key information from the process dictionary into the routing node to initialize the key information.
[0057] In one embodiment, the device session maintenance device 200 of the Internet of Things platform further includes a logout unit, a first deletion subunit, and a second deletion subunit.
[0058] The logout unit is used to receive the logout message from the device to be accessed; the first deletion subunit is used to delete the process dictionary; and the second deletion subunit is used to delete the key information from the routing node via RPC.
[0059] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the device session maintenance device 200 and each unit of the above-mentioned Internet of Things platform can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0060] The device session maintenance device of the aforementioned IoT platform can be implemented as a computer program, which can, for example... Figure 7 It runs on the computer device shown.
[0061] Please see Figure 7 , Figure 7 This is a schematic block diagram of a computer device provided in an embodiment of this application.
[0062] See Figure 7The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0063] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform a device session maintenance method for an Internet of Things (IoT) platform.
[0064] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0065] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a device session maintenance method for an Internet of Things platform.
[0066] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0067] The processor 502 is used to run a computer program 5032 stored in a memory to implement any embodiment of the device session maintenance method of the IoT platform described above.
[0068] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it 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. The general-purpose processor may be a microprocessor or any conventional processor.
[0069] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0070] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When executed by a processor, the program instructions cause the processor to perform any embodiment of the device session maintenance method for the IoT platform described above.
[0071] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0072] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0073] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0074] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0075] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0076] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0077] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Since these modifications and variations fall within the scope of the claims and their equivalents, this invention also intends to include these modifications and variations.
[0078] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A device session maintenance method for an Internet of Things (IoT) platform, characterized in that, include: LVS uses IP load balancing to connect several devices to the access node and establishes a socket session between the access node and the devices to be connected. The device information of the device to be connected is stored in the process dictionary of the access node, and the key information in the process dictionary is stored in the routing node; Receive the uplink message from the device to be accessed and update the process dictionary in the access node according to the uplink message, and update the routing node according to the key information in the updated process dictionary; If the access node changes, the system switches to the new access node to receive the uplink packets from the device to be accessed. Based on the identity information of the device to be connected, query the routing node to see if the same identity information exists; If the same identity information exists, restore and update the process dictionary of the changed access node based on the uplink message and the key information returned by the routing node; The process dictionary in the access node before the change was deleted via RPC; The key information in the updated process dictionary is then updated in the routing node.
2. The method according to claim 1, characterized in that, The steps for changing the access node include: The data is forwarded to another access node via LVS's DR mode.
3. The method according to claim 1, characterized in that, The steps of connecting several devices to the access node via LVS IP load balancing and establishing a socket session between the access node and the devices to be accessed include: Establish a link with the device to be connected through LVS's DR mode and set the keep-alive time; Obtain the IP address and port of the device to be connected to in order to listen to the socket of the device to be connected; Establish a socket session based on the socket of the device to be connected and its unique identifier.
4. The method according to claim 3, characterized in that, The method further includes: The keep-alive time is dynamically adjusted based on the number of devices to be connected.
5. The method according to claim 1, characterized in that, Before the steps of receiving the uplink message from the device to be accessed, updating the process dictionary in the access node according to the uplink message, and updating the routing node according to the key information in the updated process dictionary, the following steps are included: Receive the login message from the device to be connected; The process dictionary is initialized based on the login message; The key information in the process dictionary is stored in the routing node to initialize the key information.
6. The method according to claim 5, characterized in that, After the steps of receiving the uplink message from the device to be accessed, updating the process dictionary in the access node according to the uplink message, and updating the routing node according to the key information in the updated process dictionary, the method includes: Receive the logout message from the device to be accessed; Delete the process dictionary; The critical information is removed from the routing node via RPC.
7. A device session maintenance device for an Internet of Things (IoT) platform, characterized in that, include: The session establishment unit is used to connect several devices to be accessed to the access node through LVS IP load balancing, and to establish a socket session between the access node and the devices to be accessed. The storage unit is used to store the device information of the device to be accessed into the process dictionary of the access node, and to store the key information in the process dictionary into the routing node; The message interaction unit is used to receive the uplink message from the device to be accessed, update the process dictionary in the access node according to the uplink message, and update the routing node according to the key information in the updated process dictionary. The switching unit is used to switch to the changed access node to receive the uplink packets of the device to be accessed if the access node changes. The query unit is used to query the routing node to see if the same identity information exists based on the identity information of the device to be accessed; The recovery unit is used to recover and update the process dictionary of the changed access node based on the uplink message and the key information returned by the routing node if the same identity information exists. The deletion unit is used to delete the process dictionary in the access node before the change via RPC; The update unit is used to update the key information in the updated process dictionary to the routing node.
8. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-6.
9. A storage medium, characterized in that, The storage medium stores a computer program, which includes program instructions that, when executed by a processor, can implement the method as described in any one of claims 1-6.