A network socket-based intelligent identification service remote switch control method
Patent Information
- Application Number
- CN202611339814.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-03
AI Technical Summary
In drone cloud platforms, existing technologies cannot achieve independent, stable, and efficient remote on/off control of intelligent identification services without affecting the operation of the main service. This results in issues such as response delays, message loss, and duplicate execution caused by the coupling between the control channel and the main service.
By starting an independent service on the independent network socket port 3099, creating a control session object, parsing data exchange format messages, port-level isolation is achieved, and idempotency protection is provided through message identifiers and service status fields to ensure the reliability and uniqueness of control commands.
It achieves stability and reliability of response control under high load on the main service, keeps response latency at the millisecond level, avoids message loss and duplicate execution, and optimizes resource utilization.
Smart Images

Figure CN123035229A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of streaming media and artificial intelligence remote control technology, specifically to a method for remotely switching on and off intelligent identification services through an independent network socket channel. This method is applicable to drone cloud platform scenarios where precise control of the start and stop of intelligent identification is required without affecting the operation of the main service. Background Technology
[0002] In the intelligent recognition system of a drone cloud platform, operations and maintenance personnel need to dynamically start and stop the intelligent recognition task of specific video streams according to business needs—for example, if a drone enters standby mode, they want to turn off its recognition to save GPU resources while the streaming itself continues. This seems simple, but existing solutions have several inherent flaws.
[0003] The most critical issue is that the control channel and the main service are intertwined. The traditional approach is to make the identification and control interface a regular Hypertext Transfer Application Programming Interface (HTTP API), sharing the same HTTP port and thread pool as the stream management interface. When main service traffic peaks, the thread pool is fully loaded, control requests queue up, and response latency spikes from the usual 50 milliseconds to several seconds—during peak periods with 48 streams simultaneously streaming, the average response latency for control commands reaches 3.2 seconds. It's worth noting the unique characteristics of the drone cloud platform: the streaming media server needs to simultaneously handle dozens of drone RTMP streams, real-time stream distribution, HLS slicing, and WebRTC transcoding, resulting in a consistently high load on the main HTTP service thread pool. Actual test data for 48 streams shows that the HTTP API request queue averages 2.8 seconds, with a maximum of 4.1 seconds—cramming control commands into this queue makes the latency unbearable. So, as a fallback, could we share the same port as the main service but use a separate thread group? That won't work either: the port is still shared, and the main service's long-lived hypertext transfer connection and the identification and control connection are crammed into the same receive queue. If the main service connection experiences a burst, the establishment of the control connection has to be postponed. Only by completely separating the ports can the stability of the control channel's response be guaranteed.
[0004] There are two minor but annoying issues. First, the control protocol lacks message confirmation and status tracking: client commands are considered successful without waiting for acknowledgments, so lost messages and unresponsive recognition services go unnoticed – this has actually happened before, where maintenance personnel issued a stop command and then casually closed the page, losing the message midway, and the recognition task ran for three days before being discovered. Second, the control interface lacks idempotency protection: if three identical start commands arrive within two seconds, traditional solutions would simply start three duplicate recognition tasks, wasting GPU resources. Summary of the Invention
[0005] These problems boil down to one issue: how to build an independent control channel completely decoupled from the main service, one that includes message confirmation for data exchange formats, idempotency protection, and ensures no delays or duplicate execution of commands. To address this goal, this invention provides a remote on / off control method for intelligent identification services based on network sockets, comprising the following steps: Start an independent service listening on the network socket port (default 3099), achieving port-level isolation from the main Hypertext Transfer Service port 3090 and the Real-Time Streaming Service port 5540; create a control session object for each connection; parse the data exchange format control message to extract the message identifier, operation type, and stream identifier fields; search for a record in the identification data mapping table according to the operation type, check the current status of the business status field, if the operation type is "start" and the business status is "false", execute the actual start and set the business status to "true", if the operation type is "stop" and the business status is "true", execute the actual stop and set the business status to "false", if the status field is already the target status, ignore duplicate instructions; write the message identifier as is into the response data exchange format and return it to the client to achieve message confirmation.
[0006] The independent service is started according to the configuration file in the AiSyhk initialization function, with a default port number of 3099, completely isolated from the main hypertext transfer service port 3090 and the real-time streaming service port 5540. The advantage of port-level isolation is that even if the main service's thread pool is fully loaded, the response latency of the network socket control channel remains stable. This independent service instance is independent of the main service's hypertext transfer and real-time streaming services, and has its own thread pool, receive loop, and connection management. Compared to solutions that share ports and only have independent thread groups, its TCP handshake uses its own receive queue, so even if there is a surge in main service connections, they will not be queued.
[0007] The control session inherits from AiSessionBase, and parses the data exchange format payload of the network socket text frame in the onRecv method. The stream identifier field uses the format application name_stream name (underscore separated), and the application name and stream name are parsed by finding the position of the first underscore character in the string. The business status field is responsible for idempotency protection—start commands are executed only when the business status is false, and stop commands are executed only when the business status is true. The message identifier field is responsible for message tracking—each control command carries a unique identifier, which the server returns verbatim in the response. The client compares the message identifiers in the request and response to know that the command was indeed correctly processed by the server.
[0008] The benefits of this approach are threefold. First, in terms of channel connectivity, starting and stopping the system uses independent network socket ports and dedicated service instances, preventing it from being overwhelmed by peak traffic from the main service, and ensuring control response times remain consistently in the millisecond range. Second, in terms of reliability, the faithful transmission of message identifiers makes the execution status of each instruction traceable, virtually eliminating the risk of task loss due to message loss. Third, in terms of resources, business status verification blocks duplicate instructions; even if three identical start instructions arrive within two seconds, only one actual start will be executed, eliminating the waste of redundant identification tasks. Attached Figure Description
[0009] Figure 1 This is a flowchart of the remote switch control method based on network socket intelligent identification service in an embodiment of the present invention.
[0010] Figure 2 This is a structural diagram of the network socket independent control channel system in an embodiment of the present invention.
[0011] Figure 3 This is a comparison diagram of the response delay between hypertext transmission coupling control and network socket independent control in an embodiment of the present invention.
[0012] The meanings of the markings in the diagram are as follows: Figure 1 100 - Method entry point, 101 - Start the independent service listening port, 102 - Create a session object, 103 - Parse the message and extract fields, 104 - Determine the operation type field value, 105 - Write the message identifier number to the response as is and return a confirmation message, 106 - Method ends.
[0013] Figure 2 201-Independent service listening module, 202-Session management module, 203-Message parsing module, 204-Switch execution module, 205-Global response mechanism.
[0014] Figure 3 301 - Port coupling control scheme, 302 - Channel decoupling, 303 - Independent channel control scheme. Detailed Implementation The following is combined Figures 1 to 3 Go through the entire control process.
[0015] like Figure 1As shown, the method enters from the entry point marked 100. The first step is marked 101: the intelligent identification module initialization function of the streaming media server reads the network socket port parameters in the configuration file, starts an independent service instance listening on port 3099, and has its own thread pool and receive loop. After the console connects via the network socket protocol, the system creates a control session object for each connection according to marked 102, specifically managing the message sending and receiving on this connection. When the session receives a network socket text frame, it parses the data exchange format payload according to marked 103, retrieving the values of the message identifier, operation type, and stream identifier fields. Next, marked 104, it judges the operation type: if it is start, it parses the application name and stream name from the stream identifier field, checks the record in the identification data mapping table, and verifies the business status field—if the status is false, it executes start and sets it to true; if it is already true, it ignores it; if it is stop, similarly, if the status is true, it executes stop and sets it to false; if it is already false, it ignores it. Mark 105 writes the message identifier into the response data exchange format and sends it back to the client to complete the confirmation; marked 106, the method ends.
[0016] In terms of system architecture, Figure 2 This demonstrates the components of this independent control channel. Mark 201 is the independent service listening module, which listens for network socket connections on an independent port; Mark 202 is the session management module, which manages the control session object for each connection; Mark 203 is the message parsing module, which breaks down the message identifier, operation type, and flow identifier fields; Mark 204 is the switch execution module, which looks up the identification data mapping table and executes start / stop operations according to the service status; Mark 205 is the global response mechanism, which returns the message identifier as is and sends acknowledgment and status feedback back to the client. Figure 1 The execution of each method step corresponds to Figure 2 The interaction between these modules.
[0017] Let me explain the deployment environment. This implementation runs on a live-server streaming media server that integrates intelligent network socket control: the main hypertext transfer service port is 3090, the real-time streaming service port is 5540, and the network socket control port for the independent service is configured as 3099.
[0018] In practice, maintenance personnel start and stop the intelligent recognition of drone drone01 from the remote console: the console connects to ws: / / server:3099 and sends a text frame {"Message Identifier":"msg_001","Operation Type":"Start","Stream Identifier":"live_drone01"}. The control session parses this data exchange format in onRecv, extracting the message identifier msg_001, operation type start, and stream identifier live_drone01; it finds the position of the first underscore in the stream identifier, deciphering the application name live and stream name drone01; then, using live_drone01 as the key, it finds the record in the recognition data mapping table, the current business status is false, executes intelligent recognition start (sends a hypertext transfer start request to the intelligent recognition service), and sets the business status to true; then, it constructs a response {"Message Identifier":"msg_001","code":0,"msg":"Started"} and sends it back to the console through the same network socket connection. The console confirms the execution of the command by matching the message identifiers on both sides.
[0019] The scenario of repeated commands was also verified: three identical startup commands were sent within two seconds. The first command set the business status to false (normal startup) and then set it to true. The latter two commands, upon verifying that the status was already true, were ignored and returned {"message identifier":"msg_002","code":1,"msg":"already started"} to indicate that the program was already running. Idempotency protection here prevents the GPU waste caused by repeated startups.
[0020] The stress comparison best illustrates the point. When the main Hypertext Transfer service was overloaded with 48 streams (the Hypertext Transfer application programming interface response latency spiked to 3.2 seconds), the network socket control channel, running on a separate service and a separate port 3099, maintained a stable response latency of 48 to 52 milliseconds. Actual test data shows that in the same scenario with 48 streams and a fully loaded Hypertext Transfer thread pool, the average control command response latency for the shared port and independent thread pool solution was 1.8 seconds (maximum 3.5 seconds), while the average response latency for the independent service and independent port solution was 49 milliseconds (maximum 53 milliseconds)—the stability of the control channel differs by two orders of magnitude.
[0021] Figure 3 The comparison of response latency between the two schemes is shown. For example... Figure 3 As shown in mark 301, the latency of the port coupling control scheme increases linearly with the number of concurrent requests, averaging 3.2 seconds at full load for 48-channel streaming; Figure 3 As indicated by reference 302, this invention decouples the channel through a port-level independent service, controlling the channel to exclusively use port 3099 and the thread pool; as shown in Figure 302. Figure 3As shown in the figure 303, the independent channel control scheme has an average response time of only 49 milliseconds and a fluctuation range of 48 to 53 milliseconds when the main service is fully loaded, which is far more stable than the port coupling scheme.
Claims
1. A remote switch control method based on network socket intelligent identification service, characterized in that, Includes at least the following steps: In the intelligent identification module initialization function of the streaming media server, an independent service instance is started to listen to the port according to the network socket port parameter in the configuration file. This independent service uses different port numbers to achieve port-level isolation from the main hypertext transfer service and the real-time streaming service. The default value of the network socket port is 3099, the default value of the main hypertext transfer service port is 3090, and the default value of the real-time streaming service port is 5540. When the intelligent identification control client connects to the independent service via the network socket protocol, a control session object is created for each connection to handle message sending and receiving on that connection. When the control session object receives a network socket text frame, it parses the data exchange format string in the frame payload and extracts the values of the message identifier field, operation type field, and stream identifier field. The value of the operation type field is then determined: if it is "started," the application name and stream name are parsed from the stream identifier field, the corresponding record is searched in the identification data mapping table, and the current value of the business status field is checked. If the business status is false, the intelligent identification start operation is executed, and the business status is set. If the business status is true, the repeated start command is ignored; if it is stopped, the application name and stream name are parsed from the stream identifier field, the corresponding record is searched in the identification data mapping table, and the current value of the business status field is checked. If the business status is true, the intelligent identification stop operation is executed and the business status is set to false; if the business status is false, the repeated stop command is ignored. The message identifier is written as is into the message identifier field of the response data exchange format and returned to the intelligent identification control client through a network socket connection to realize message confirmation, so that the client compares the message identifiers in the request and response to confirm that the command has been correctly processed on the server.
2. The method according to claim 1, characterized in that, The default value of the network socket port parameter is 3099. The independent service instance has an independent thread pool and an independent receive loop. Compared with the main hypertext transfer service sharing the port and only allocating an independent thread group, it is not affected when the main service connection is interrupted.
3. The method according to claim 1, characterized in that, The format of the stream identifier field is application name_stream name, and the parsing method is to find the position of the first underscore character, with the application name preceding it and the stream name following it.
4. The method according to claim 1, characterized in that, The business status field is used for idempotency protection. When the operation type is "start" and the business status is already true, the status information is returned directly without repeating the start operation. When the operation type is "stop" and the business status is already false, the status information is returned directly without repeating the stop operation.
5. A remote switch control system based on network sockets with intelligent identification service, characterized in that, include: An independent service module is used to listen for network socket connections on an independent port, which is completely isolated from the ports of the main Hypertext Transfer Service and Real-Time Streaming Service at the port level. The session management module is used to create control session objects for each network socket connection to manage message sending and receiving; the data exchange format parsing module is used to parse the message identifier, operation type, and stream identifier fields in control messages; The idempotency control module is used to prevent duplicate start and stop commands by checking the status of the business status field; the message confirmation module is used to write the message identifier in the request into the response body and return it to the client as is.
6. A streaming media server device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the system of claim 5.
7. The system according to claim 5, characterized in that, The independent service module has its own thread pool and independent receiving loop. Compared with the main hypertext transfer service, which shares a port and only allocates independent thread groups, it is not affected when the main service connection is interrupted.
8. A streaming media server for a drone cloud platform, characterized in that, The system comprising any one of claims 5 or 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 4.
