A method and system for solving the abnormal number of gateway TCP connections during data collection
By monitoring the number of gateway TCP connections in real time through the data acquisition server and automatically clearing it to zero when it reaches a set value, the problem of increased connection numbers caused by abnormal data acquisition equipment is solved, ensuring the stability and real-time performance of data acquisition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2026-03-03
AI Technical Summary
When the data acquisition equipment or PLC malfunctions or experiences an abnormal power outage, the number of TCP connections to the gateway continues to increase, causing the gateway to lose connection with the data acquisition equipment or PLC. As a result, the data acquisition server is unable to obtain data, and the gateway needs to be manually restarted to resolve the issue.
The gateway TCP connection count is monitored in real time by the data acquisition server. When the connection count reaches the set restart value, the source code of the gateway settings interface is automatically called to refresh and clear the TCP connection count, so as to avoid the connection count reaching the critical value and ensure stable communication.
In the event of malfunctions in the data acquisition equipment or PLC, the gateway TCP connection count is automatically restored, ensuring that the data acquisition server continuously acquires data. This avoids human intervention and communication interruptions, and improves the real-time performance and accuracy of data acquisition.
Smart Images

Figure CN116055359B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data acquisition, and in particular to a method and system for resolving abnormal TCP connection counts at a gateway during data acquisition. Background Technology
[0002] Data acquisition devices or PLCs refer to devices or PLCs that collect data. The collected data often needs to be transmitted to a data acquisition server for further processing. When using data acquisition devices or PLCs for data acquisition, some older devices or PLCs may lack a TCP communication interface or be unable to change their IP address. In such cases, a gateway is often added to establish communication between the data acquisition device / PLC and the data acquisition server. However, if the data acquisition device / PLC malfunctions or experiences a power outage, the number of TCP connections to the gateway will continuously increase. When the number of TCP connections reaches the gateway's connection limit, the connection between the gateway and the data acquisition device / PLC will be lost. Even after the data acquisition device / PLC recovers, the gateway's TCP connection count remains at the critical level, preventing the data acquisition server from receiving the collected data. Summary of the Invention
[0003] To address the aforementioned technical problems, this invention provides a method and system for resolving abnormal gateway TCP connection counts during data acquisition. The purpose is to solve the problem that when the data acquisition device or PLC itself malfunctions or experiences an abnormal power outage, the TCP connection count continuously increases, and even after the data acquisition device or PLC recovers from the malfunction, the gateway TCP connection count remains at a critical value, preventing the data acquisition server from obtaining the acquired data.
[0004] According to a first aspect of the present invention, the present invention provides a method for resolving abnormal TCP connection counts during data acquisition, comprising the following steps:
[0005] S1. Control the data acquisition server to monitor the number of gateway TCP connections to the gateway connected to the data acquisition equipment or data acquisition PLC in real time;
[0006] S2. Determine whether the number of TCP connections to the gateway has reached the set TCP connection restart value. If yes, proceed to step S3; otherwise, return to step S1. Wherein, the TCP connection restart value is less than the threshold value allowed by the gateway for connections.
[0007] S3: Control the data acquisition server to call the gateway settings interface source code and automatically refresh and clear the gateway TCP connection count.
[0008] Furthermore, in the method of the present invention for resolving abnormal gateway TCP connection count during data acquisition, a switch is also connected between the gateway and the data acquisition server to enable communication between the gateway and the data acquisition server.
[0009] Furthermore, in the method of the present invention for resolving abnormal TCP connection count of gateway during data acquisition, step S1 is specifically implemented as follows: the data acquisition server creates a connection based on the WebSocket protocol through the gateway IP information and captures and monitors the TCP connection count of the gateway in real time.
[0010] Furthermore, in the method of the present invention for resolving abnormal gateway TCP connection count during data acquisition, step S3 is specifically implemented as follows:
[0011] When the number of TCP connections to the gateway reaches the set TCP connection count restart value, the data acquisition server triggers a soft restart parameter in the gateway parameter configuration interface. The gateway parameter interface automatically refreshes and restarts, and the number of TCP connections is cleared to zero.
[0012] Furthermore, in the method of the present invention for resolving abnormal gateway TCP connection count during data acquisition, the data acquisition server is an IoT server.
[0013] According to another aspect of the present invention, the present invention also provides a system for resolving abnormal TCP connection counts during data acquisition at a gateway, comprising the following modules:
[0014] The quantity monitoring module is used to control the data acquisition server to monitor the number of gateway TCP connections to the gateway connected to the data acquisition equipment or data acquisition PLC in real time;
[0015] The judgment and processing module is used to determine whether the number of TCP connections of the gateway has reached the set TCP connection restart value. If so, it enters the refresh and clear module; otherwise, it returns to the number monitoring module. The TCP connection restart value is less than the threshold value allowed by the gateway.
[0016] The refresh and reset module is used to control the data acquisition server to call the gateway settings interface source code and automatically refresh and reset the gateway TCP connection count.
[0017] Furthermore, in a system for resolving abnormal TCP connection counts of a gateway during data acquisition according to the present invention, a switch is also connected between the gateway and the data acquisition server to enable communication between the gateway and the data acquisition server.
[0018] Furthermore, in a system for resolving abnormal gateway TCP connection counts during data acquisition according to the present invention, the specific implementation of the quantity monitoring module is as follows: the data acquisition server creates a connection based on the WebSocket protocol using the gateway IP information, and captures and monitors the gateway's TCP connection count in real time.
[0019] Furthermore, in a system for resolving abnormal TCP connection counts during data acquisition according to the present invention, the refresh and clearing module is specifically implemented as follows:
[0020] When the number of TCP connections to the gateway reaches the set TCP connection count restart value, the data acquisition server triggers a soft restart parameter in the gateway parameter configuration interface. The gateway parameter interface automatically refreshes and restarts, and the number of TCP connections is cleared to zero.
[0021] Furthermore, in a system for resolving abnormal gateway TCP connection counts during data acquisition according to the present invention, the data acquisition server is an IoT server.
[0022] This invention relates to a method and system for resolving abnormal gateway TCP connection counts during data acquisition. The data acquisition server monitors the gateway TCP connection count connected to the data acquisition device or PLC in real time. It determines whether the gateway TCP connection count has reached a set TCP connection count restart value. If so, the data acquisition server calls the gateway settings interface source code to automatically refresh and clear the gateway TCP connection count; otherwise, it monitors the gateway TCP connection count. The TCP connection count restart value is less than the gateway's allowed connection threshold. This invention solves the problem of older data acquisition devices or PLCs failing to provide TCP interfaces or being unable to change their IP addresses. It also solves the problem of abnormal gateway TCP connection counts causing the data acquisition server to be unable to collect data when the data acquisition device or PLC itself malfunctions, requiring manual power-off and restart of the gateway. Attached Figure Description
[0023] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings:
[0024] Figure 1 This is a hardware architecture diagram of an embodiment of the method for resolving abnormal TCP connection count of a gateway during data acquisition according to the present invention;
[0025] Figure 2 This is a flowchart of an embodiment of the method of the present invention for resolving abnormal TCP connection count of gateway during data acquisition;
[0026] Figure 3 This is a schematic diagram of an embodiment of the method of the present invention for resolving abnormal TCP connection count of gateway during data acquisition. Detailed Implementation
[0027] To provide a clearer understanding of the technical features, objectives, and effects of the present invention, specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0028] refer to Figure 1 , Figure 1This is a hardware architecture diagram of an embodiment of the method for resolving abnormal gateway TCP connection counts during data acquisition according to the present invention. The hardware included in this embodiment includes: a data acquisition server, a switch, gateways 1 to n, and data acquisition PLCs 1 to n. The data acquisition server communicates with gateways 1 to n via the switch, and gateways 1 to n communicate with data acquisition PLCs 1 to n one-to-one.
[0029] The data acquisition server can utilize an IoT server, with gateways 1 through n connected one-to-one with data acquisition PLCs 1 through n, resolving issues where some data acquisition PLCs cannot provide TCP interfaces or change their IP addresses. The gateway connects to a switch, transmitting data collected by the data acquisition PLCs to the data acquisition server, which monitors and acquires the data in real time. In traditional solutions, when the gateway experiences an anomaly or a power outage, the number of TCP connections to the data acquisition device or PLC will continuously increase. When the number of TCP connections reaches the gateway's connection limit, the gateway will disconnect the connected data acquisition PLCs. At this point, the data acquisition server cannot acquire data from the disconnected PLCs. Manual intervention is required to locate and power-restart the gateway, clearing the gateway's TCP connection count to zero and restoring normal operation. Only then can the data acquisition server resume acquiring data from the disconnected PLC.
[0030] It should be understood that this embodiment uses a data acquisition PLC for illustration. In other embodiments of the present invention, a data acquisition device may also be used to implement the solution of the present invention, or a data acquisition PLC and a data acquisition device may be used to acquire data simultaneously.
[0031] It should be understood that in this embodiment, each gateway is connected to the data acquisition PLC in a one-to-one manner. In other embodiments of the present invention, each gateway is connected to the data acquisition PLC in a one-to-many manner, that is, one gateway connects to multiple data acquisition PLCs. In other embodiments of the present invention, each gateway is connected to the data acquisition PLC in a hybrid one-to-one and one-to-many manner.
[0032] It should be understood that only one switch is shown in this embodiment. In some other cases where the data transmission volume is small, a switch may not be necessary, and a gateway may be used to establish a communication connection between the data acquisition server and the gateway. In other cases where there are many data acquisition PLCs and / or data acquisition devices, multiple switches may be used for data exchange.
[0033] refer to Figure 2 , Figure 2 This is a flowchart of an embodiment of the method for resolving abnormal TCP connection counts of a gateway during data acquisition according to the present invention. The method for resolving abnormal TCP connection counts of a gateway during data acquisition provided in this embodiment includes the following steps:
[0034] S1. Control the data acquisition server to monitor the number of gateway TCP connections to the gateway connected to the data acquisition equipment or data acquisition PLC in real time.
[0035] Every gateway has a configuration interface. By logging into the web page using the gateway's IP address, you can obtain detailed gateway parameter configuration information and real-time information on the number of TCP connections. The server creates a connection based on the WebSocket protocol using the gateway's IP information and monitors the number of TCP connections to the gateway in real time.
[0036] S2. Determine whether the number of TCP connections to the gateway has reached the set TCP connection restart value. If yes, proceed to step S3; otherwise, return to step S1. Wherein, the TCP connection restart value is less than the threshold value allowed by the gateway for connections.
[0037] The threshold for allowed connections by the gateway is limited by the gateway's hardware. As long as the number of TCP connections is less than the gateway's own limit, communication will not be interrupted; it can be zero, but it cannot be equal to or greater than this limit. Therefore, when the number of TCP connections reaches the gateway's allowed connection threshold, the gateway will disconnect the data acquisition device or PLC with which it has established a TCP connection. To avoid this, this invention sets the TCP connection restart value to be less than the gateway's allowed connection threshold. When the number of disconnected gateway TCP connections reaches the set TCP connection restart value, step S3 is entered to clear the gateway's TCP connection count to zero. It should be understood that while the TCP connection restart value is less than the gateway's allowed connection threshold, it should also be a relatively large value to avoid the gateway's TCP connection count being cleared too frequently. Generally, a restart value of more than half of the threshold is preferable.
[0038] S3: Control the data acquisition server to call the gateway settings interface source code and automatically refresh and clear the gateway TCP connection count.
[0039] For example, if the gateway's allowed connection threshold is 12, the data acquisition server resets the TCP connection count to 8. The data acquisition server monitors the TCP connection count in real time. When the TCP connection count increases to 8, the data acquisition server calls the gateway's settings interface source code to automatically refresh and clear the TCP connection count. In this way, the gateway's TCP connection count will never reach the threshold, ensuring that the communication between the data acquisition server and the data acquisition PLC and data acquisition equipment is not affected by abnormal situations, and ensuring the real-time performance and accuracy of the collected data.
[0040] refer to Figure 3 , Figure 3 This is a schematic diagram of an embodiment of the method for resolving abnormal TCP connection counts of a gateway during data acquisition according to the present invention. The system for resolving abnormal TCP connection counts of a gateway during data acquisition in this embodiment includes a quantity monitoring module 31, a judgment and processing module 32, and a refresh and clearing module 33.
[0041] The quantity monitoring module 31 is used to control the data acquisition server to monitor the number of gateway TCP connections connected to the data acquisition equipment or data acquisition PLC in real time. Specifically, the quantity monitoring module 31 is implemented as follows: the data acquisition server establishes a connection based on the WebSocket protocol using the gateway IP information, and captures and monitors the number of gateway TCP connections in real time.
[0042] The judgment and processing module 32 is used to determine whether the number of TCP connections of the gateway has reached the set TCP connection restart value. If so, it enters the refresh and clear module 33; otherwise, it returns to the number monitoring module 31. The TCP connection restart value is less than the threshold value allowed by the gateway.
[0043] The refresh and reset module 33 is used to control the data acquisition server to call the gateway settings interface source code and automatically refresh and reset the gateway TCP connection count. Specifically, when the gateway TCP connection count reaches the set TCP connection restart value, the data acquisition server triggers a soft restart parameter in the gateway parameter configuration interface. The gateway parameter interface automatically refreshes and restarts, and the TCP connection count is reset to zero.
[0044] Preferably, a switch is also connected between the gateway and the data acquisition server to enable communication between the gateway and the data acquisition server.
[0045] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method for resolving abnormal TCP connection counts at a gateway during data acquisition, characterized in that, It includes the following steps: S1. Control the data acquisition server to monitor the number of gateway TCP connections to the gateway connected to the data acquisition equipment or data acquisition PLC in real time; S2. Determine whether the number of TCP connections to the gateway has reached the set TCP connection restart value. If yes, proceed to step S3; otherwise, return to step S1. Wherein, the TCP connection restart value is less than the threshold value allowed by the gateway for connections. S3: Control the data acquisition server to call the gateway settings interface source code and automatically refresh and clear the gateway TCP connection count.
2. The method for resolving abnormal TCP connection counts during data acquisition as described in claim 1, characterized in that, A switch is also connected between the gateway and the data acquisition server to enable communication between the gateway and the data acquisition server.
3. The method for resolving abnormal TCP connection counts during data acquisition as described in claim 1, characterized in that, The specific implementation method of step S1 is as follows: the data acquisition server creates a connection based on the WebSocket protocol through the gateway IP information and captures and monitors the number of TCP connections of the gateway in real time.
4. The method for resolving abnormal TCP connection counts during data acquisition as described in claim 3, characterized in that, The specific implementation method of step S3 is as follows: When the number of TCP connections to the gateway reaches the set TCP connection count restart value, the data acquisition server triggers a soft restart parameter in the gateway parameter configuration interface. The gateway parameter interface automatically refreshes and restarts, and the number of TCP connections is cleared to zero.
5. The method for resolving abnormal TCP connection counts during data acquisition as described in claim 1, characterized in that, The data acquisition server is an IoT server.
6. A system for resolving abnormal gateway TCP connection counts during data acquisition, characterized in that, It includes the following modules: The quantity monitoring module is used to control the data acquisition server to monitor the number of gateway TCP connections to the gateway connected to the data acquisition equipment or data acquisition PLC in real time; The judgment and processing module is used to determine whether the number of TCP connections of the gateway has reached the set TCP connection restart value. If so, it enters the refresh and clear module; otherwise, it returns to the number monitoring module. The TCP connection restart value is less than the threshold value allowed by the gateway. The refresh and reset module is used to control the data acquisition server to call the gateway settings interface source code and automatically refresh and reset the gateway TCP connection count.
7. The system for resolving abnormal TCP connection counts during data acquisition as described in claim 6, characterized in that, A switch is also connected between the gateway and the data acquisition server to enable communication between the gateway and the data acquisition server.
8. The system for resolving abnormal TCP connection counts during data acquisition as described in claim 6, characterized in that, The specific implementation of the quantity monitoring module is as follows: the data acquisition server creates a connection based on the WebSocket protocol through the gateway IP information and captures and monitors the number of TCP connections to the gateway in real time.
9. The system for resolving abnormal TCP connection counts during data acquisition as described in claim 8, characterized in that, The specific implementation method of the refresh and clear module is as follows: When the number of TCP connections to the gateway reaches the set TCP connection count restart value, the data acquisition server triggers a soft restart parameter in the gateway parameter configuration interface. The gateway parameter interface automatically refreshes and restarts, and the number of TCP connections is cleared to zero.
10. The system for resolving abnormal TCP connection counts during data acquisition as described in claim 6, characterized in that, The data acquisition server is an IoT server.
Citation Information
Patent Citations
Communication protocol management method and device, electronic equipment and storage medium
CN113595837A
Intelligent gateway data collecting and pushing method
CN114793188A