NAS device and server connection linkage management method, device and equipment

CN122554325APending Publication Date: 2026-08-11SHENZHEN GREEN CONNECTION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610442236.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-03
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0003]然而,实践发现,传统的WebSocket服务器重连方式只是简单地通过预设时间间隔进行重连的尝试,在网络环境差时易因频繁重连造成资源浪费,可能对服务器造成压力,且重连延迟时间只是简单地递增,无法有效应对网络波动,重连效率较低,不利于实现稳定可靠的连接

Benefits of technology

实施本发明能够通过监听NAS设备登录服务和设备连接服务的状态变化事件,实现NAS设备状态与WebSocket服务器连接状态的自动联动管理,能够依据设备实际状态精准地管理连接,避免不必要的连接尝试或连接中断处理不及时的情况,提高连接管理的有效性和准确性,且当网络状态显示NAS设备从不可用变为可用时,能够迅速确定触发与WebSocket服务器相匹配的重连事件,及时响应设备网络可用性的变化,确保在设备恢复可用后尽快重新建立连接,有利于保障数据传输和业务交互的连续性,减少因设备不可用导致的业务中断时间,以及采用基于指数退避算法确定重连延迟时间,并设定预设的最大重连次数来执行重连操,能够使重连延迟时间随着重连次数的增加而呈指数级增长,避免在短时间内频繁重连对网络和服务器造成过大压力,实现有效应对网络波动,能够提高NAS设备与WebSocket服务器的重连效率,从而能够实现稳定可靠的连接,同时预设最大重连次数可以防止无限次重连导致的资源浪费,有效优化了重连过程。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122554325A_ABST
    Figure CN122554325A_ABST
Patent Text Reader

Abstract

This invention relates to the field of communication technology and discloses a method, apparatus, and device for the coordinated management of a NAS device and a server connection. The method includes: controlling the connection between the NAS device and a WebSocket server by monitoring status change events of the NAS device, where the status change events include login status change events and / or connection status change events; determining that the NAS device triggers a reconnection event matching the WebSocket server when the network status indicates that the NAS device has changed from a network unavailable state to a network available state; and performing a reconnection operation between the NAS device and the WebSocket server based on a reconnection delay time determined by an exponential backoff algorithm and a preset maximum number of reconnections. Therefore, implementing this invention can improve the reconnection efficiency between the NAS device and the WebSocket server, which is beneficial for achieving a stable and reliable connection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a method, apparatus, and device for the coordinated management of NAS devices and servers. Background Technology

[0002] In the management scenario of NAS devices connecting to WebSocket servers, how to reconnect when the connection is lost is extremely important. The existing reconnection method mainly involves issuing a network disconnection event when the WebSocket server connection is lost, so as to trigger the reconnection thread. For example, within a preset reconnection time period, it attempts to reconnect once every preset time (such as 5 seconds) until the reconnection is successful.

[0003] However, practice has shown that traditional WebSocket server reconnection methods simply attempt to reconnect at preset time intervals. In poor network conditions, frequent reconnections can waste resources and potentially strain the server. Furthermore, the reconnection latency merely increases incrementally, failing to effectively address network fluctuations and resulting in low reconnection efficiency, which is detrimental to achieving stable and reliable connections. Therefore, proposing a technical solution that improves the reconnection efficiency between NAS devices and WebSocket servers to achieve stable and reliable connections is of paramount importance. Summary of the Invention

[0004] This invention provides a method, apparatus, and device for the linkage management of NAS devices and server connections, which can improve the reconnection efficiency between NAS devices and WebSocket servers and facilitate stable and reliable connections.

[0005] To address the aforementioned technical problems, the first aspect of this invention discloses a method for the coordinated management of a NAS device and a server connection. This method is applied to an electronic device with an application installed, wherein the electronic device is communicatively connected to a NAS device and accesses the NAS device through the application. The application is used to manage the communication connection of the NAS device, and the method includes: By listening to the status change events of the NAS device, the connection between the NAS device and the WebSocket server is controlled. The status change events include login status change events and / or connection status change events. When the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, it is determined that the NAS device initiates a reconnection event matching the WebSocket server; and it is determined whether the NAS device and the WebSocket server are reconnecting for the first time. When it is determined that the NAS device and the WebSocket server are reconnecting for the first time, a preset reconnection baseline delay is obtained; and the reconnection baseline delay is used as the reconnection delay time to perform the first reconnection attempt operation between the NAS device and the WebSocket server. When it is determined that the NAS device and the WebSocket server are not reconnecting for the first time, based on the exponential backoff algorithm, the reconnection delay time corresponding to the current number of reconnections is determined according to the reconnection baseline delay, the determined current number of reconnections, and the preset maximum number of reconnections; and the reconnection attempt operation is performed on the NAS device and the WebSocket server according to the reconnection delay time corresponding to the current number of reconnections. Determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections; When it is determined that the NAS device and the WebSocket server fail to reconnect within the current number of reconnections, the reconnection attempt operation is performed again on the NAS device and the WebSocket server according to the maximum number of reconnections, so that the last reconnection attempt operation is less than or equal to the maximum number of reconnections, which is either the maximum number of reconnections or the current number of reconnections when the NAS device and the WebSocket server successfully reconnect.

[0006] As an optional implementation, in the first aspect of the present invention, the method further includes: Determine whether the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is a target disconnected state. The target disconnected state indicates that the NAS device has closed the connection channel of the target object without the user actively closing the target object. The target object includes the NAS device and / or the WebSocket server. When it is determined that the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is the target disconnected state, the operation of determining that the NAS device starts a reconnection event that matches the WebSocket server is triggered. When it is determined that the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is not the target disconnected state, the user operation data corresponding to the NAS device is detected; when the user operation data corresponding to the NAS device indicates that the user has triggered the operation data to open the connection channel of the target object, the operation of determining that the NAS device starts a reconnection event that matches the WebSocket server is triggered.

[0007] As an optional implementation, in the first aspect of the present invention, the NAS device has a multi-level architecture including at least an integration layer, a service layer and a core layer; And, the step of controlling the connection between the NAS device and the WebSocket server by listening to the status change events of the NAS device includes: Based on the integration layer, the device login service of the NAS device is monitored, and the device login service is used to indicate login status change events of the NAS device; Based on the integration layer, the device connection service of the NAS device is monitored, and the device connection service is used to indicate connection status change events of the NAS device; Based on the core layer, the device information of the NAS device is obtained according to the device login service, and a connection instance between the NAS device and the WebSocket server is created according to the device information of the NAS device. Based on the business layer, according to the device connection service and the connection instance, the request header information is configured to initiate a connection request between the NAS device and the WebSocket server; and according to the connection request, the connection between the NAS device and the WebSocket server is controlled.

[0008] As an optional implementation, in the first aspect of the present invention, the device information includes the access gateway address and access token information of the NAS device, or the device information includes the certificate information of the NAS device; And, the step of creating a connection instance between the NAS device and the WebSocket server based on the device information of the NAS device includes: When the device information includes the access gateway address and access token information of the NAS device, the system performs automatic protocol conversion on the NAS device based on the access gateway address and access token information, detects the URL protocol of the NAS device, and obtains the protocol detection result; and constructs the initial URL parameters of the WebSocket server based on the protocol detection result; and creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters; or, When the device information includes the certificate information of the NAS device, an automatic certificate configuration process is triggered to parse the certificate information to create a certificate fixing verifier; and based on the certificate fixing verifier, a connection instance between the NAS device and the WebSocket server is created.

[0009] As an optional implementation, in the first aspect of the present invention, creating a connection instance between the NAS device and the WebSocket server based on the initial URL parameters includes: Based on the determined language configuration parameters of the NAS device, the initial URL parameters are configured to obtain the target URL parameters; Based on the target URL parameters, a connection instance between the NAS device and the WebSocket server is created; Furthermore, the language configuration parameters are determined in the following manner: Based on the business layer, the first language parameters of the NAS device are determined according to the device connection service; and the language configuration parameters of the NAS device are determined according to the first language parameters of the NAS device and the second language parameters of the obtained WebSocket server.

[0010] As an optional implementation, in the first aspect of the present invention, the application is provided with a heartbeat keep-alive and recovery mechanism, which is used to initiate a heartbeat detection operation to send a heartbeat message for the NAS device once every preset heartbeat interval, and save the heartbeat message of the NAS device. Furthermore, the method further includes: Obtain the connection result between the NAS device and the WebSocket server; When the connection between the NAS device and the WebSocket server is lost, the heartbeat detection operation is stopped. When the connection result between the NAS device and the WebSocket server indicates a successful connection, the heartbeat detection result of the application is obtained, and when the heartbeat detection result indicates that there is a heartbeat message for the NAS device, the heartbeat detection operation is restarted. When the connection between the NAS device and the WebSocket server is successfully reconnected, the heartbeat detection operation is resumed.

[0011] A second aspect of this invention discloses a linkage management device for connecting a NAS device and a server. The device is applied to an electronic device with an application installed, and the electronic device is communicatively connected to a NAS device, accessing the NAS device through the application. The application is used to manage the communication connection of the NAS device, and the device includes: A connection module is used to control the NAS device to connect to a WebSocket server by listening to status change events of the NAS device, wherein the status change events include login status change events and / or connection status change events. The determination module is used to determine when the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, and to determine that the NAS device initiates a reconnection event that matches the WebSocket server. The determination module is used to determine whether the NAS device and the WebSocket server are reconnecting for the first time; The reconnection module is used to obtain a preset reconnection baseline delay when the determination module determines that the NAS device and the WebSocket server are reconnecting for the first time; and use the reconnection baseline delay as the reconnection delay time to perform the first reconnection attempt operation between the NAS device and the WebSocket server. The determining module is further configured to, when the judging module determines that the NAS device and the WebSocket server are not reconnecting for the first time, determine the reconnection delay time corresponding to the current reconnection number based on the exponential backoff algorithm, according to the reconnection baseline delay, the determined current reconnection number, and the preset maximum reconnection number; The reconnection module is further configured to perform the reconnection attempt operation between the NAS device and the WebSocket server based on the reconnection delay time corresponding to the current reconnection count; The judgment module is also used to determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections; The reconnection module is further configured to, when the determination module determines that the NAS device and the WebSocket server fail to reconnect within the current reconnection count, perform the reconnection attempt operation on the NAS device and the WebSocket server again according to the maximum reconnection count, so that the last reconnection attempt operation is less than or equal to the maximum reconnection count, which is either the maximum reconnection count or the current reconnection count when the NAS device and the WebSocket server successfully reconnect.

[0012] As an optional implementation, in a second aspect of the present invention, the determining module is further configured to determine whether the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is a target disconnected state, wherein the target disconnected state indicates that the NAS device has not actively closed the connection channel of the target object, and the target object includes the NAS device and / or the WebSocket server; when it is determined that the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is the target disconnected state, the determining module is triggered to perform the operation of determining that the NAS device starts a reconnection event matching the WebSocket server; The device also includes: The detection module is used to detect user operation data corresponding to the NAS device when the judgment module determines that the current state of the NAS device is not the target disconnected state; and to trigger the determination module to perform the operation of determining that the NAS device starts a reconnection event matching the WebSocket server when the user operation data corresponding to the NAS device indicates that the user has triggered the operation data to open the connection channel of the target object.

[0013] As an optional implementation, in the second aspect of the present invention, the NAS device has a multi-level architecture including at least an integration layer, a service layer and a core layer; Furthermore, the connection module controls the connection between the NAS device and the WebSocket server by listening to status change events of the NAS device, including the following specific methods: Based on the integration layer, the device login service of the NAS device is monitored, and the device login service is used to indicate login status change events of the NAS device; Based on the integration layer, the device connection service of the NAS device is monitored, and the device connection service is used to indicate connection status change events of the NAS device; Based on the core layer, the device information of the NAS device is obtained according to the device login service, and a connection instance between the NAS device and the WebSocket server is created according to the device information of the NAS device. Based on the business layer, according to the device connection service and the connection instance, the request header information is configured to initiate a connection request between the NAS device and the WebSocket server; and according to the connection request, the connection between the NAS device and the WebSocket server is controlled.

[0014] As an optional implementation, in the second aspect of the present invention, the specific method by which the connection module creates a connection instance between the NAS device and the WebSocket server based on the device information of the NAS device includes: When the device information includes the access gateway address and access token information of the NAS device, the system performs automatic protocol conversion on the NAS device based on the access gateway address and access token information, detects the URL protocol of the NAS device, and obtains the protocol detection result; and constructs the initial URL parameters of the WebSocket server based on the protocol detection result; and creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters; or, When the device information includes the certificate information of the NAS device, an automatic certificate configuration process is triggered to parse the certificate information to create a certificate fixing verifier; and based on the certificate fixing verifier, a connection instance between the NAS device and the WebSocket server is created.

[0015] As an optional implementation, in a second aspect of the present invention, the specific method by which the connection module creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters includes: Based on the determined language configuration parameters of the NAS device, the initial URL parameters are configured to obtain the target URL parameters; Based on the target URL parameters, a connection instance between the NAS device and the WebSocket server is created; Furthermore, the language configuration parameters are determined in the following manner: Based on the business layer, the first language parameters of the NAS device are determined according to the device connection service; and the language configuration parameters of the NAS device are determined according to the first language parameters of the NAS device and the second language parameters of the obtained WebSocket server.

[0016] As an optional implementation, in the second aspect of the present invention, the application is provided with a heartbeat keep-alive and recovery mechanism, which is used to initiate a heartbeat detection operation to send a heartbeat message for the NAS device once every preset heartbeat interval, and save the heartbeat message of the NAS device. The device also includes: The acquisition module is used to acquire the connection result between the NAS device and the WebSocket server; The heartbeat management module is used to stop the heartbeat detection operation when the connection between the NAS device and the WebSocket server is lost. The heartbeat management module is further configured to obtain the heartbeat detection result of the application when the connection result between the NAS device and the WebSocket server indicates a successful connection, and to restart the heartbeat detection operation when the heartbeat detection result indicates that there is a heartbeat message for the NAS device. The heartbeat management module is also used to resume the heartbeat detection operation when the connection result between the NAS device and the WebSocket server is a successful reconnection.

[0017] A third aspect of the present invention discloses an electronic device, the electronic device comprising: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the linkage management method for NAS device and server connection disclosed in the first aspect of the present invention.

[0018] A fourth aspect of this invention discloses a linkage management system for connecting a NAS device and a server. The system includes at least a linkage management device as described in the second aspect of this invention, and a NAS device communicatively connected to the linkage management device. The linkage management device performs a connection operation between the NAS device and a WebSocket server according to the linkage management method for connecting a NAS device and a server as described in the first aspect of this invention. Alternatively, The system includes at least the electronic device as described in the third aspect of the present invention, and a NAS device communicatively connected to the electronic device; wherein the electronic device performs a connection operation between the NAS device and the WebSocket server according to the linkage management method for NAS device and server connection as described in the first aspect of the present invention.

[0019] The fifth aspect of this invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the linkage management method for connecting NAS devices and servers disclosed in the first aspect of this invention.

[0020] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: Implementing this invention enables automatic linkage management of NAS device status and WebSocket server connection status by monitoring status change events of NAS device login service and device connection service. It can accurately manage connections based on the actual device status, avoiding unnecessary connection attempts or untimely handling of connection interruptions, thus improving the effectiveness and accuracy of connection management. Furthermore, when the network status shows the NAS device changing from unavailable to available, it can quickly determine and trigger a reconnection event matching the WebSocket server, responding promptly to changes in device network availability and ensuring a rapid re-establishment of the connection after the device becomes available again. This helps ensure the continuity of data transmission and business interaction, reducing business interruption time caused by device unavailability. The invention also employs an exponential backoff algorithm to determine the reconnection delay time and sets a preset maximum number of reconnections. This allows the reconnection delay time to increase exponentially with the number of reconnections, avoiding excessive pressure on the network and server from frequent reconnections in a short period, effectively responding to network fluctuations, improving the reconnection efficiency between the NAS device and the WebSocket server, and thus achieving a stable and reliable connection. Simultaneously, the preset maximum number of reconnections prevents resource waste caused by unlimited reconnections, effectively optimizing the reconnection process. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a flowchart illustrating a linkage management method for connecting a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 2 This is a flowchart illustrating another method for the coordinated management of NAS devices and servers disclosed in an embodiment of the present invention. Figure 3 This is a schematic diagram of the structure of a linkage management device for connecting a NAS device and a server, as disclosed in an embodiment of the present invention; Figure 4 This is a schematic diagram of another linkage management device for connecting a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 5 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of a linkage management system for connecting NAS devices and servers, as disclosed in an embodiment of the present invention; Figure 7This is a schematic diagram of another linkage management system for connecting NAS devices and servers disclosed in an embodiment of the present invention. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. 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.

[0024] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.

[0025] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0026] This invention discloses a method, apparatus, and device for the coordinated management of NAS device and server connections. By monitoring status change events in the NAS device login service and device connection service, it achieves automatic coordinated management of the NAS device status and the WebSocket server connection status. It can accurately manage connections based on the actual device status, avoiding unnecessary connection attempts or untimely handling of connection interruptions, thus improving the effectiveness and accuracy of connection management. Furthermore, when the network status shows the NAS device changing from unavailable to available, it can quickly determine and trigger a reconnection event matching the WebSocket server, responding promptly to changes in device network availability and ensuring timely recovery of the device. Re-establishing the connection as soon as it becomes available ensures the continuity of data transmission and business interaction, reduces business interruption time caused by device unavailability, and uses an exponential backoff algorithm to determine the reconnection latency. By setting a preset maximum number of reconnections, the reconnection latency increases exponentially with the number of reconnections, avoiding excessive pressure on the network and server from frequent reconnections in a short period. This effectively copes with network fluctuations, improves the reconnection efficiency between the NAS device and the WebSocket server, and thus achieves a stable and reliable connection. Furthermore, setting a preset maximum number of reconnections prevents resource waste caused by unlimited reconnections, effectively optimizing the reconnection process. These points are explained in detail below.

[0027] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for the coordinated management of a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 1 The described method for managing the connection between a NAS device and a server can be applied to electronic devices with installed applications. The electronic device communicates with a NAS device and accesses the NAS device through the application, which manages the communication connection of the NAS device. This method can also be applied to a device for managing the connection between a NAS device and a server. This device may include a management device or a management server, where the management server may be a cloud server or a local server. This embodiment of the invention does not impose any limitations. Figure 1 As shown, the linkage management method between this NAS device and the server can include the following operations: 101. Control the connection between the NAS device and the WebSocket server by listening to the status change events of the NAS device.

[0028] In this embodiment of the invention, the NAS device has a multi-layered architecture comprising at least an integration layer, a business layer, and a core layer. Optionally, the integration layer includes a NAS device login service, a NAS device connection service, and a NAS device model protocol, used to implement device login / disconnection, device reconnection, and device address change monitoring; the business layer can implement business logic management through service interfaces, and includes functions such as subscription management, message sending, and language switching, used to implement NAS device status monitoring and WebSocket connection linkage; the core layer can manage the connection to the WebSocket server, and includes an event callback protocol, used to implement intelligent reconnection, heartbeat reporting, and network monitoring, etc., without limitation in this embodiment of the invention.

[0029] In this embodiment of the invention, the status change events include login status change events and / or connection status change events. Specifically, the NAS device's login status change events are monitored through the NAS device's device login service, and the NAS device's connection status change events are monitored through the NAS device's device connection service.

[0030] 102. When the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, determine when the NAS device initiates a reconnection event that matches the WebSocket server.

[0031] In this embodiment of the invention, optionally, the network state may include at least the current network state; or, the network state may include at least the current network state and may also include network change states. Optionally, the current network state may include a network unavailable state, or a network available state. Network change states may include a change from a network unavailable state to a network available state, or a change from a network available state to a network unavailable state; this embodiment of the invention does not impose any limitations.

[0032] 103. Determine if this is the first time the NAS device and the WebSocket server are reconnecting.

[0033] In this embodiment of the invention, when the judgment result of step 103 is yes, that is, when it is determined that the NAS device and the WebSocket server are reconnecting for the first time, step 104 is triggered; when the judgment result of step 103 is no, that is, when it is determined that the NAS device and the WebSocket server are not reconnecting for the first time, step 105 is triggered.

[0034] 104. Obtain the preset reconnection baseline delay; and use the reconnection baseline delay as the reconnection delay time to perform the first reconnection attempt between the NAS device and the WebSocket server.

[0035] 105. Based on the exponential backoff algorithm, determine the reconnection delay time corresponding to the current number of reconnections according to the reconnection baseline delay, the determined current number of reconnections, and the preset maximum number of reconnections.

[0036] In this embodiment of the invention, the exponential backoff algorithm is used to perform reconnection operations between the NAS device and the WebSocket server through an exponentially increasing reconnection latency. The maximum number of reconnections is used to limit the number of times the above reconnection operation is performed.

[0037] In this embodiment of the invention, the formula for calculating the reconnection delay time can be: delay = min(initialDelay * 2^(reconnectCount-1), maxDelay), where delay is the reconnection delay time, min represents the minimum value, initialDelay is the reconnection baseline delay, reconnectCount is the current reconnection count, and maxDelay is the maximum reconnection count (e.g., 5 times).

[0038] 106. Based on the reconnection delay time corresponding to the current number of reconnections, perform a reconnection attempt between the NAS device and the WebSocket server.

[0039] 107. Determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections.

[0040] In this embodiment of the invention, when the judgment result of step 107 is yes, that is, when it is determined that the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections, this process can end; when the judgment result of step 107 is no, that is, when it is determined that the NAS device and the WebSocket server have failed to reconnect within the current number of reconnections, step 108 is triggered.

[0041] 108. Based on the maximum number of reconnections, perform another reconnection attempt between the NAS device and the WebSocket server, so that the last reconnection attempt is less than or equal to the maximum number of reconnections, or the current number of reconnections when the NAS device and the WebSocket server successfully reconnect.

[0042] It is evident that implementation Figure 1The described NAS device and server connection linkage management method can automatically link and manage the NAS device status and WebSocket server connection status by monitoring the status change events of the NAS device login service and device connection service. It can accurately manage connections based on the actual device status, avoiding unnecessary connection attempts or untimely handling of connection interruptions, thus improving the effectiveness and accuracy of connection management. Furthermore, when the network status shows that the NAS device changes from unavailable to available, it can quickly determine and trigger a reconnection event matching the WebSocket server, responding promptly to changes in device network availability and ensuring that the connection is re-established as soon as the device becomes available again. This helps ensure the continuity of data transmission and business interaction, reducing business interruption time caused by device unavailability. Moreover, by using an exponential backoff algorithm to determine the reconnection latency and setting a preset maximum number of reconnections, the reconnection latency increases exponentially with the number of reconnections, avoiding excessive pressure on the network and server from frequent reconnections in a short period, effectively responding to network fluctuations, and improving the connection between the NAS device and the WebSocket server. This system improves reconnection efficiency, enabling stable and reliable connections. A preset maximum number of reconnections prevents resource waste caused by unlimited reconnections, effectively optimizing the reconnection process. Specifically, for the first reconnection, a preset reconnection baseline latency is obtained, and a reconnection attempt is performed. When it's not the first reconnection, the latency is calculated based on the baseline latency, the current number of reconnections, and the preset maximum number of reconnections. This causes the reconnection latency to increase exponentially with the number of reconnections. By dynamically adjusting the reconnection latency, the system can rationally allocate resources at different reconnection stages. A shorter latency is used in the initial reconnection phase to quickly attempt connection recovery. As the number of reconnections increases, the latency is appropriately extended to reduce unnecessary resource consumption and optimize resource utilization. Furthermore, by determining whether the reconnection is successful, and if it fails, a reconnection attempt is performed again based on the maximum number of reconnections. This ensures that the last reconnection attempt either reaches the maximum number of reconnections or, if successful, the current number of reconnections is less than or equal to the maximum number of reconnections. This helps avoid resource waste caused by unlimited reconnections, such as network bandwidth, device power consumption, and server resources, ensuring rational utilization of system resources.

[0043] Example 2 Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for the coordinated management of a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 2The described method for managing the connection between a NAS device and a server can be applied to electronic devices with installed applications. The electronic device communicates with a NAS device and accesses the NAS device through the application, which manages the communication connection of the NAS device. This method can also be applied to a device for managing the connection between a NAS device and a server. This device may include a management device or a management server, where the management server may be a cloud server or a local server. This embodiment of the invention does not impose any limitations. Figure 2 As shown, the linkage management method between this NAS device and the server can include the following operations: 201. Control the connection between the NAS device and the WebSocket server by listening to the status change events of the NAS device.

[0044] 202. When the network status of the NAS device changes from a network unavailable state to a network available state, determine whether the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is the target disconnected state.

[0045] In this embodiment of the invention, the target disconnect state indicates that the NAS device has not actively closed the connection channel of the target object, and the target object includes the NAS device and / or the WebSocket server.

[0046] In this embodiment of the invention, when the judgment result of step 202 is negative, step 203 is triggered; when the judgment result of step 202 is positive, step 204 is triggered.

[0047] 203. Detect the user operation data corresponding to the NAS device.

[0048] In this embodiment of the invention, when the user operation data corresponding to the NAS device is detected to indicate that the user has triggered the operation data to open the connection channel of the target object, step 204 is triggered.

[0049] 204. Determine the reconnection event that matches the WebSocket server when the NAS device starts.

[0050] In this embodiment of the invention, specifically, the connection between the NAS device and the WebSocket server is controlled by listening to the status change events of the NAS device; and when the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, it is determined whether the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is a target disconnected state. When it is determined that the status change event of the NAS device's device connection service indicates that the current state of the NAS device is the target disconnected state, the NAS device is instructed to initiate a reconnection event that matches the WebSocket server. When it is determined that the status change event of the NAS device's device connection service indicates that the current state of the NAS device is not the target disconnected state, the corresponding user operation data of the NAS device is detected; when the corresponding user operation data of the NAS device indicates that the user has triggered the operation data to open the connection channel of the target object, the NAS device is determined to start a reconnection event that matches the WebSocket server.

[0051] 205. Determine if this is the first time the NAS device and the WebSocket server are reconnecting.

[0052] In this embodiment of the invention, when the judgment result of step 205 is yes, that is, when it is determined that the NAS device and the WebSocket server are reconnecting for the first time, step 206 is triggered; when the judgment result of step 205 is no, that is, when it is determined that the NAS device and the WebSocket server are not reconnecting for the first time, step 206 is triggered.

[0053] 206. Obtain the preset reconnection baseline delay; and use the reconnection baseline delay as the reconnection delay time to perform the first reconnection attempt between the NAS device and the WebSocket server.

[0054] 207. Based on the exponential backoff algorithm, determine the reconnection delay time corresponding to the current number of reconnections according to the reconnection baseline delay, the determined current number of reconnections, and the preset maximum number of reconnections.

[0055] In this embodiment of the invention, the formula for calculating the reconnection delay time can be: delay = min(initialDelay * 2^(reconnectCount-1), maxDelay), where delay is the reconnection delay time, min represents the minimum value, initialDelay is the reconnection baseline delay, reconnectCount is the current reconnection count, and maxDelay is the maximum reconnection count (e.g., 5 times).

[0056] 208. Based on the reconnection delay time corresponding to the current number of reconnections, perform a reconnection attempt between the NAS device and the WebSocket server.

[0057] 209. Determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections.

[0058] In this embodiment of the invention, when the judgment result of step 209 is yes, that is, when it is determined that the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections, this process can end; when the judgment result of step 207 is no, that is, when it is determined that the NAS device and the WebSocket server have failed to reconnect within the current number of reconnections, step 210 is triggered.

[0059] 210. Based on the maximum number of reconnections, perform another reconnection attempt between the NAS device and the WebSocket server, so that the last reconnection attempt is less than or equal to the maximum number of reconnections, or the current number of reconnections when the NAS device and the WebSocket server successfully reconnect.

[0060] In this embodiment of the invention, for other descriptions of steps 201 and 204-210, please refer to the detailed description of steps 101-108 in Embodiment 1. These descriptions will not be repeated in this embodiment of the invention.

[0061] It is evident that implementation Figure 2The described NAS device and server connection linkage management method can automatically link and manage the NAS device status and WebSocket server connection status by monitoring the status change events of the NAS device login service and device connection service. It can accurately manage connections based on the actual device status, avoiding unnecessary connection attempts or untimely handling of connection interruptions, thus improving the effectiveness and accuracy of connection management. Furthermore, when the network status shows that the NAS device changes from unavailable to available, it can quickly determine and trigger a reconnection event matching the WebSocket server, responding promptly to changes in device network availability and ensuring that the connection is re-established as soon as the device becomes available again. This helps ensure the continuity of data transmission and business interaction, reducing business interruption time caused by device unavailability. Moreover, by using an exponential backoff algorithm to determine the reconnection latency and setting a preset maximum number of reconnections, the reconnection latency increases exponentially with the number of reconnections, avoiding excessive pressure on the network and server from frequent reconnections in a short period, effectively responding to network fluctuations, and improving the connection between the NAS device and the WebSocket server. This system improves reconnection efficiency, enabling stable and reliable connections. A preset maximum number of reconnections prevents resource waste caused by unlimited reconnections, effectively optimizing the reconnection process. Specifically, for the first reconnection, a preset reconnection baseline delay is obtained, and a reconnection attempt is performed. When it's not the first reconnection, the delay time is calculated based on the baseline delay, the current number of reconnections, and the preset maximum number of reconnections. This causes the reconnection delay time to increase exponentially with the number of reconnections. By dynamically adjusting the reconnection delay time, the system can rationally allocate resources at different reconnection stages. A shorter delay time is used in the initial reconnection phase to quickly attempt connection recovery. As the number of reconnections increases, the delay time is appropriately extended to reduce unnecessary resource consumption and optimize resource utilization. Furthermore, by determining whether the reconnection is successful, and if it fails, a reconnection attempt is performed again based on the maximum number of reconnections. This ensures that the last reconnection attempt either reaches the maximum number of reconnections or, if successful, the current number of reconnections is less than or equal to the maximum number of reconnections. This helps avoid resource waste caused by unlimited reconnections, such as network bandwidth, device power consumption, and server resources, ensuring rational utilization of system resources.Furthermore, by monitoring NAS device status change events, particularly the transition from unavailable to available network status, the system can trigger subsequent judgments. This ensures that connection operations are only considered when the device has basic network communication capabilities, avoiding invalid connection attempts in the absence of network coverage. This provides a reliable prerequisite for subsequent connection decisions, ensuring the effectiveness of connection operations. When the network is available, the system further determines whether the device's connection service status change event indicates a connection not actively closed by the user. If the result is yes, a reconnection event is automatically initiated without user intervention, enabling rapid response to device connection anomalies and timely connection restoration, reducing user waiting time and improving reconnection efficiency. If the result is no, a reconnection event is initiated only when the user actively initiates the connection, fully considering personalized user needs and allowing users to actively control connection operations according to their own wishes, providing greater flexibility and control and improving the user experience.

[0062] In an optional embodiment, step 201 above, controlling the connection between the NAS device and the WebSocket server by listening to status change events of the NAS device, includes: Based on the integration layer, the device login service of the NAS device is monitored. The device login service is used to indicate the login status change events of the NAS device. Based on the integration layer, the device connection service of the NAS device is monitored. The device connection service is used to indicate the connection status change events of the NAS device. Based on the core layer, the device information of the NAS device is obtained according to the device login service, and a connection instance between the NAS device and the WebSocket server is created according to the device information of the NAS device. Based on the business layer, the request header information is configured according to the device connection service and the connection instance to initiate a connection request between the NAS device and the WebSocket server; and the connection between the NAS device and the WebSocket server is controlled according to the connection request.

[0063] In this embodiment of the invention, optionally, the device login service is further configured to generate a first type of connection processing instruction based on a login status change event, wherein the first type of connection processing instruction includes a connection establishment instruction and / or a connection cleanup instruction. Optionally, the device connection service is further configured to generate a second type of connection processing instruction based on a connection status change event, wherein the second type of connection processing instruction includes a connection reconstruction instruction and / or a connection update instruction; this embodiment of the invention does not impose limitations on this.

[0064] In this embodiment of the invention, the device information includes the access gateway address and access token information of the NAS device, or the device information includes the certificate information of the NAS device.

[0065] As can be seen, this optional embodiment can achieve precise monitoring of device login and connection status, effective management of device information, and intelligent initiation and control of connection requests through the collaborative work of the multi-level architecture of the NAS device (including the integration layer, business layer, and core layer). By monitoring the device login service and device connection service of the NAS device through the integration layer, the system can obtain the device login status change event and connection status change event of the device respectively, and comprehensively grasp the login status and connection status changes of the NAS device. By obtaining the device information of the NAS device based on the device login service obtained by the integration layer, the core layer obtains the device information of the NAS device and creates a connection instance with the WebSocket server. By configuring the request header information and initiating the connection request based on the device connection service provided by the integration layer and the connection instance created by the core layer, the business layer controls the connection between the NAS device and the WebSocket server. In this way, through the collaborative work of the multi-level architecture, the system can reasonably allocate resources according to the actual status of the device and business needs.

[0066] In this optional embodiment, as an optional implementation, creating a connection instance between the NAS device and the WebSocket server based on the device information of the NAS device includes: When the device information includes the NAS device's access gateway address and access token information, the system automatically performs protocol conversion on the NAS device based on the access gateway address and access token information, detects the NAS device's URL protocol, obtains the protocol detection result, constructs the initial URL parameters for the WebSocket server based on the protocol detection result, and creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters; or, When the device information includes the certificate information of the NAS device, the automatic certificate configuration process is triggered to parse the certificate information to create a certificate pinning verifier; and based on the certificate pinning verifier, a connection instance between the NAS device and the WebSocket server is created.

[0067] For example, automatic protocol conversion could be to convert HTTP / HTTPS to WS / WSS, and the configuration request header could be one of "Accept-Language", "bid", "User-Feature", or "Client-Id".

[0068] As can be seen, this optional implementation can flexibly create connection instances with the WebSocket server by adopting automatic protocol conversion and automatic certificate configuration processes according to different device information of the NAS device. Specifically, when the device information includes the access gateway address and access token information, automatic protocol conversion is performed on the NAS device to convert the protocol originally used by the NAS device into a protocol compatible with the WebSocket server. This helps to improve the success rate of communication between the NAS device and the WebSocket server and overcomes the limitations caused by protocol differences. When the device information includes certificate information, the automatic certificate configuration process is triggered to parse the certificate information and create a certificate verification tool. This allows the certificate information to be applied to the connection establishment process quickly and accurately, which helps to improve the efficiency and accuracy of certificate management, thereby improving the efficiency and accuracy of connection establishment.

[0069] In this optional implementation, optionally, based on the initial URL parameters, a connection instance between the NAS device and the WebSocket server is created, including: Based on the determined language configuration parameters of the NAS device, configure the language of the initial URL parameters to obtain the target URL parameters; Based on the target URL parameters, create a connection instance between the NAS device and the WebSocket server; Furthermore, the language configuration parameters are determined in the following way: Based on the business layer, the first language parameter of the NAS device is determined according to the device connection service; and the language configuration parameter of the NAS device is determined according to the first language parameter of the NAS device and the second language parameter obtained from the WebSocket server.

[0070] In this embodiment of the invention, the language configuration parameter can be a parameter that configures the first language parameter to match the second language parameter.

[0071] As can be seen, this optional implementation can also create a connection instance by configuring the initial URL parameters based on the language parameters of the NAS device and the WebSocket server through the collaborative work of the business layer and the core layer. This helps to improve the language adaptability of the connection creation between the NAS device and the server, and the convenience of user operation is improved under the guidance of language configuration, thereby improving the user experience. Furthermore, by accurately constructing the target URL parameters, it is helpful to ensure that the URL parameters contain the correct language information, so that the NAS device can accurately establish a connection with the WebSocket server, reduce connection errors or data transmission anomalies caused by language mismatch, and further improve the stability and reliability of the connection.

[0072] In another optional embodiment, the application includes a heartbeat keep-alive and recovery mechanism to initiate heartbeat detection to send a heartbeat message for the NAS device every preset heartbeat interval and to save the NAS device's heartbeat messages. The method may also include: Obtain the connection results between the NAS device and the WebSocket server; When the connection between the NAS device and the WebSocket server is lost, stop the heartbeat detection operation. When the connection result between the NAS device and the WebSocket server indicates a successful connection, obtain the application's heartbeat detection result, and when the heartbeat detection result indicates that there is a heartbeat message for the NAS device, restart the heartbeat detection operation; When the connection between the NAS device and the WebSocket server is successfully reconnected, the heartbeat detection operation is resumed.

[0073] As can be seen, this optional embodiment can flexibly control the heartbeat detection operation based on the connection result between the NAS device and the WebSocket server. Specifically, when the connection result between the NAS device and the WebSocket server is a disconnection, the heartbeat detection operation is stopped, thereby reducing the consumption of network bandwidth and system resources. When the connection result is a successful reconnection, the heartbeat detection operation is resumed to ensure that the connection channel can remain stable during subsequent use. Furthermore, in the case of a successful connection, the application's heartbeat detection result can be obtained to determine whether there is a heartbeat message for the NAS device. If there is, it indicates that the connection is in a normal state. At this time, restarting the heartbeat detection operation can achieve continuous monitoring of whether the NAS device connection channel is abnormal, which is conducive to timely detection of connection anomalies. It is also possible to make corresponding operational adjustments quickly based on different connection results. Whether the connection is disconnected, successful, or successful reconnection, the heartbeat detection operation can be stopped, restarted, or resumed immediately, which can quickly adapt to changes in connection status, help improve the overall efficiency and flexibility of the system, and ensure that it maintains a good operating state under various connection conditions.

[0074] Example 3 Please see Figure 3 , Figure 3 This is a schematic diagram of a linkage management device for connecting a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 3The described linkage management device for connecting NAS devices and servers can be applied to electronic devices with installed applications. The electronic device communicates with a NAS device and accesses the NAS device through the application, which manages the communication connection of the NAS device. The device may include a management device or a management server, wherein the management server may be a cloud server or a local server; this embodiment of the invention is not limited thereto. Figure 3 As shown, the linkage management device connecting the NAS device and the server may include: The connection module 301 is used to control the connection between the NAS device and the WebSocket server by listening to the status change events of the NAS device. The status change events include login status change events and / or connection status change events.

[0075] The determination module 302 is used to determine when the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, and to determine when the NAS device initiates a reconnection event that matches the WebSocket server.

[0076] The judgment module 303 is used to determine whether the NAS device and the WebSocket server are reconnecting for the first time.

[0077] The reconnection module 304 is used to obtain a preset reconnection baseline delay when the judgment module 303 determines that the NAS device and the WebSocket server are reconnecting for the first time; and use the reconnection baseline delay as the reconnection delay time to perform the first reconnection attempt operation between the NAS device and the WebSocket server.

[0078] The determination module 302 is also used to determine the reconnection delay time corresponding to the current number of reconnections based on the exponential backoff algorithm, according to the reconnection baseline delay, the determined current number of reconnections, and the preset maximum number of reconnections when the judgment module 303 determines that the NAS device and the WebSocket server are not reconnecting for the first time.

[0079] The reconnection module 304 is also used to perform a reconnection attempt between the NAS device and the WebSocket server based on the reconnection delay time corresponding to the current number of reconnections.

[0080] The judgment module 303 is also used to determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnection attempts.

[0081] The reconnection module 304 is also used to perform a reconnection attempt operation on the NAS device and the WebSocket server again according to the maximum reconnection count when the judgment module 303 determines that the NAS device and the WebSocket server have failed to reconnect within the current reconnection count, so that the last reconnection attempt operation is less than or equal to the maximum reconnection count or the current reconnection count when the NAS device and the WebSocket server reconnect successfully.

[0082] It is evident that implementation Figure 3 The described NAS device and server connection linkage management device can automatically manage the NAS device status and WebSocket server connection status by monitoring status change events of the NAS device login service and device connection service. It can accurately manage connections based on the actual device status, avoiding unnecessary connection attempts or untimely connection interruption handling, thus improving the effectiveness and accuracy of connection management. Furthermore, when the network status shows the NAS device changing from unavailable to available, it can quickly determine and trigger a reconnection event matching the WebSocket server, responding promptly to changes in network availability and ensuring a rapid re-establishment of the connection after the device becomes available again. This helps ensure the continuity of data transmission and business interaction, reducing business interruption time caused by device unavailability. It also employs an exponential backoff algorithm to determine the reconnection delay time and sets a preset maximum number of reconnections for execution. This allows the reconnection delay time to increase exponentially with the number of reconnections, avoiding excessive pressure on the network and server from frequent reconnections in a short period, effectively responding to network fluctuations, and improving the connection between the NAS device and the WebSocket server. This system improves reconnection efficiency, enabling stable and reliable connections. A preset maximum number of reconnections prevents resource waste caused by unlimited reconnections, effectively optimizing the reconnection process. Specifically, for the first reconnection, a preset reconnection baseline latency is obtained, and a reconnection attempt is performed. When it's not the first reconnection, the latency is calculated based on the baseline latency, the current number of reconnections, and the preset maximum number of reconnections. This causes the reconnection latency to increase exponentially with the number of reconnections. By dynamically adjusting the reconnection latency, the system can rationally allocate resources at different reconnection stages. A shorter latency is used in the initial reconnection phase to quickly attempt connection recovery. As the number of reconnections increases, the latency is appropriately extended to reduce unnecessary resource consumption and optimize resource utilization. Furthermore, by determining whether the reconnection is successful, and if it fails, a reconnection attempt is performed again based on the maximum number of reconnections. This ensures that the last reconnection attempt either reaches the maximum number of reconnections or, if successful, the current number of reconnections is less than or equal to the maximum number of reconnections. This helps avoid resource waste caused by unlimited reconnections, such as network bandwidth, device power consumption, and server resources, ensuring rational utilization of system resources.

[0083] In an optional embodiment, the determining module 303 is further configured to determine whether the status change event of the NAS device's device connection service indicates that the current state of the NAS device is a target disconnected state. A target disconnected state indicates that the NAS device has not actively closed the connection channel to the target object, which includes the NAS device and / or the WebSocket server. When it is determined that the status change event of the NAS device's device connection service indicates that the current state of the NAS device is a target disconnected state, the determining module 302 is triggered to perform the operation of determining whether the NAS device initiates a reconnection event matching the WebSocket server. And, as... Figure 4 As shown, Figure 4 This is a schematic diagram of another linkage management device for connecting a NAS device and a server, as disclosed in an embodiment of the present invention. Figure 4 As shown, the device may further include: The detection module 305 is used to detect the user operation data corresponding to the NAS device when the judgment module 303 determines that the current state of the NAS device is not the target disconnected state; and to trigger the determination module 302 to perform the operation of determining that the NAS device starts a reconnection event that matches the WebSocket server when the user operation data corresponding to the NAS device indicates that the user has triggered the operation data to open the connection channel of the target object.

[0084] It is evident that implementation Figure 4 The described device can also monitor NAS device status change events, paying particular attention to the transition from unavailable to available network status. This serves as the basis for triggering subsequent judgments, ensuring that connection operations are only considered when the device has basic network communication capabilities. This avoids invalid connection attempts in the absence of network coverage, providing a reliable prerequisite for subsequent connection decisions and ensuring the effectiveness of connection operations. Furthermore, when the network is available, it further determines whether the device connection service status change event indicates a connection not actively closed by the user. If the result is yes, a reconnection event is automatically initiated without user intervention, enabling rapid response to device connection anomalies and timely connection restoration, reducing user waiting time and improving reconnection efficiency. If the result is no, a reconnection event is initiated only when the user actively initiates the connection, fully considering the user's personalized needs and allowing users to actively control connection operations according to their own wishes, providing greater flexibility and control and improving the user experience.

[0085] In another optional embodiment, the NAS device has a multi-layered architecture including at least an integration layer, a service layer, and a core layer. Furthermore, the connection module 301 controls the connection between the NAS device and the WebSocket server by listening to status change events of the NAS device, specifically in the following ways: Based on the integration layer, the device login service of the NAS device is monitored. The device login service is used to indicate the login status change events of the NAS device. Based on the integration layer, the device connection service of the NAS device is monitored. The device connection service is used to indicate the connection status change events of the NAS device. Based on the core layer, the device information of the NAS device is obtained according to the device login service, and a connection instance between the NAS device and the WebSocket server is created according to the device information of the NAS device. Based on the business layer, the request header information is configured according to the device connection service and the connection instance to initiate a connection request between the NAS device and the WebSocket server; and the connection between the NAS device and the WebSocket server is controlled according to the connection request.

[0086] As can be seen, this optional embodiment can achieve precise monitoring of device login and connection status, effective management of device information, and intelligent initiation and control of connection requests through the collaborative work of the multi-level architecture of the NAS device (including the integration layer, business layer, and core layer). By monitoring the device login service and device connection service of the NAS device through the integration layer, the system can obtain the device login status change event and connection status change event of the device respectively, and comprehensively grasp the login status and connection status changes of the NAS device. By obtaining the device information of the NAS device based on the device login service obtained by the integration layer, the core layer obtains the device information of the NAS device and creates a connection instance with the WebSocket server. By configuring the request header information and initiating the connection request based on the device connection service provided by the integration layer and the connection instance created by the core layer, the business layer controls the connection between the NAS device and the WebSocket server. In this way, through the collaborative work of the multi-level architecture, the system can reasonably allocate resources according to the actual status of the device and business needs.

[0087] In this optional embodiment, as an optional implementation, the specific method by which the connection module 301 creates a connection instance between the NAS device and the WebSocket server based on the device information of the NAS device may include: When the device information includes the NAS device's access gateway address and access token information, the system automatically performs protocol conversion on the NAS device based on the access gateway address and access token information, detects the NAS device's URL protocol, obtains the protocol detection result, constructs the initial URL parameters for the WebSocket server based on the protocol detection result, and creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters; or, When the device information includes the certificate information of the NAS device, the automatic certificate configuration process is triggered to parse the certificate information to create a certificate pinning verifier; and based on the certificate pinning verifier, a connection instance between the NAS device and the WebSocket server is created.

[0088] As can be seen, this optional implementation can flexibly create connection instances with the WebSocket server by adopting automatic protocol conversion and automatic certificate configuration processes according to different device information of the NAS device. Specifically, when the device information includes the access gateway address and access token information, automatic protocol conversion is performed on the NAS device to convert the protocol originally used by the NAS device into a protocol compatible with the WebSocket server. This helps to improve the success rate of communication between the NAS device and the WebSocket server and overcomes the limitations caused by protocol differences. When the device information includes certificate information, the automatic certificate configuration process is triggered to parse the certificate information and create a certificate verification tool. This allows the certificate information to be applied to the connection establishment process quickly and accurately, which helps to improve the efficiency and accuracy of certificate management, thereby improving the efficiency and accuracy of connection establishment.

[0089] In this optional implementation, the connection module 301 may optionally create a connection instance between the NAS device and the WebSocket server based on the initial URL parameters in the following ways: Based on the determined language configuration parameters of the NAS device, configure the language of the initial URL parameters to obtain the target URL parameters; Based on the target URL parameters, create a connection instance between the NAS device and the WebSocket server; Furthermore, the language configuration parameters are determined in the following way: Based on the business layer, the first language parameter of the NAS device is determined according to the device connection service; and the language configuration parameter of the NAS device is determined according to the first language parameter of the NAS device and the second language parameter obtained from the WebSocket server.

[0090] As can be seen, this optional implementation can also create a connection instance by configuring the initial URL parameters based on the language parameters of the NAS device and the WebSocket server through the collaborative work of the business layer and the core layer. This helps to improve the language adaptability of the connection creation between the NAS device and the server, and the convenience of user operation is improved under the guidance of language configuration, thereby improving the user experience. Furthermore, by accurately constructing the target URL parameters, it is helpful to ensure that the URL parameters contain the correct language information, so that the NAS device can accurately establish a connection with the WebSocket server, reduce connection errors or data transmission anomalies caused by language mismatch, and further improve the stability and reliability of the connection.

[0091] In another optional embodiment, the application is configured with a heartbeat keep-alive and recovery mechanism to initiate a heartbeat detection operation, sending a heartbeat message for the NAS device every preset heartbeat interval, and saving the NAS device's heartbeat message. And, as... Figure 4 As shown, the device may further include: Module 306 is used to obtain the connection result between the NAS device and the WebSocket server.

[0092] The heartbeat management module 307 is used to stop the heartbeat detection operation when the connection between the NAS device and the WebSocket server is lost.

[0093] The heartbeat management module 307 is also used to obtain the heartbeat detection result of the application when the connection result between the NAS device and the WebSocket server indicates that the connection is successful, and to restart the heartbeat detection operation when the heartbeat detection result indicates that there is a heartbeat message for the NAS device.

[0094] The heartbeat management module 307 is also used to resume heartbeat detection when the connection result between the NAS device and the WebSocket server is a successful reconnection.

[0095] As can be seen, this optional embodiment can flexibly control the heartbeat detection operation based on the connection result between the NAS device and the WebSocket server. Specifically, when the connection result between the NAS device and the WebSocket server is a disconnection, the heartbeat detection operation is stopped, thereby reducing the consumption of network bandwidth and system resources. When the connection result is a successful reconnection, the heartbeat detection operation is resumed to ensure that the connection channel can remain stable during subsequent use. Furthermore, in the case of a successful connection, the application's heartbeat detection result can be obtained to determine whether there is a heartbeat message for the NAS device. If there is, it indicates that the connection is in a normal state. At this time, restarting the heartbeat detection operation can achieve continuous monitoring of whether the NAS device connection channel is abnormal, which is conducive to timely detection of connection anomalies. It is also possible to make corresponding operational adjustments quickly based on different connection results. Whether the connection is disconnected, successful, or successful reconnection, the heartbeat detection operation can be stopped, restarted, or resumed immediately, which can quickly adapt to changes in connection status, help improve the overall efficiency and flexibility of the system, and ensure that it maintains a good operating state under various connection conditions.

[0096] Example 4 Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. For example... Figure 5 As shown, the electronic device may include: Memory 401 storing executable program code; Processor 402 coupled to memory 401; The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the linkage management method for connecting NAS devices and servers described in Embodiment 1 or Embodiment 2 of the present invention.

[0097] Example 5 Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a linkage management system for connecting NAS devices and servers, as disclosed in an embodiment of the present invention. Figure 6 As shown, the system includes at least a linkage management device 30 as described in Embodiment 3 of the present invention, and a NAS device 50 communicatively connected to the linkage management device 30. The linkage management device 30 performs a connection operation between the NAS device and the WebSocket server according to the linkage management method for connecting the NAS device and the server as described in Embodiment 1 or Embodiment 2 of the present invention; or, Please see Figure 7 , Figure 7 This is a schematic diagram of another linkage management system for connecting NAS devices and servers disclosed in an embodiment of the present invention, as shown below. Figure 7 As shown, the system includes at least an electronic device 40 as described in Embodiment 4 of the present invention, and a NAS device 50 that is communicatively connected to the electronic device 40. The electronic device 40 performs connection operations between the NAS device and the WebSocket server according to the linkage management method for NAS device and server connection described in Embodiment 1 or Embodiment 2 of the present invention.

[0098] Example 6 This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute the steps in the linkage management method for connecting NAS devices and servers described in Embodiment 1 or Embodiment 2 of this invention.

[0099] Example 7 This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the linkage management method for NAS device and server connection described in Embodiment 1 or Embodiment 2.

[0100] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0101] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0102] Finally, it should be noted that the linkage management method, apparatus, and device for connecting a NAS device and a server disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for coordinated management of NAS devices and servers, characterized in that, The method is applied to an electronic device with an application installed, the electronic device being communicatively connected to a NAS device and accessing the NAS device through the application, the application being used to manage the communication connection of the NAS device, and the method comprising: By listening to the status change events of the NAS device, the connection between the NAS device and the WebSocket server is controlled. The status change events include login status change events and / or connection status change events. When the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, it is determined that the NAS device initiates a reconnection event matching the WebSocket server; and it is determined whether the NAS device and the WebSocket server are reconnecting for the first time. When it is determined that the NAS device and the WebSocket server are reconnecting for the first time, a preset reconnection baseline delay is obtained; and the reconnection baseline delay is used as the reconnection delay time to perform the first reconnection attempt operation between the NAS device and the WebSocket server. When it is determined that the NAS device and the WebSocket server are not reconnecting for the first time, based on the exponential backoff algorithm, the reconnection delay time corresponding to the current number of reconnections is determined according to the reconnection baseline delay, the determined current number of reconnections, and the preset maximum number of reconnections; and the reconnection attempt operation is performed on the NAS device and the WebSocket server according to the reconnection delay time corresponding to the current number of reconnections. Determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections; When it is determined that the NAS device and the WebSocket server fail to reconnect within the current number of reconnections, the reconnection attempt operation is performed again on the NAS device and the WebSocket server according to the maximum number of reconnections, so that the last reconnection attempt operation is less than or equal to the maximum number of reconnections, which is either the maximum number of reconnections or the current number of reconnections when the NAS device and the WebSocket server successfully reconnect.

2. The linkage management method for connecting NAS devices and servers according to claim 1, characterized in that, The method further includes: Determine whether the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is a target disconnected state. The target disconnected state indicates that the NAS device has closed the connection channel of the target object without the user actively closing the target object. The target object includes the NAS device and / or the WebSocket server. When it is determined that the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is the target disconnected state, the operation of determining that the NAS device starts a reconnection event that matches the WebSocket server is triggered. When it is determined that the status change event of the device connection service of the NAS device indicates that the current state of the NAS device is not the target disconnected state, the user operation data corresponding to the NAS device is detected; when the user operation data corresponding to the NAS device indicates that the user has triggered the operation data to open the connection channel of the target object, the operation of determining that the NAS device starts a reconnection event that matches the WebSocket server is triggered.

3. The linkage management method for connecting NAS devices and servers according to claim 1 or 2, characterized in that, The NAS device has a multi-level architecture that includes at least an integration layer, a service layer, and a core layer. And, the step of controlling the connection between the NAS device and the WebSocket server by listening to the status change events of the NAS device includes: Based on the integration layer, the device login service of the NAS device is monitored, and the device login service is used to indicate login status change events of the NAS device; Based on the integration layer, the device connection service of the NAS device is monitored, and the device connection service is used to indicate connection status change events of the NAS device; Based on the core layer, the device information of the NAS device is obtained according to the device login service, and a connection instance between the NAS device and the WebSocket server is created according to the device information of the NAS device. Based on the business layer, according to the device connection service and the connection instance, the request header information is configured to initiate a connection request between the NAS device and the WebSocket server; and according to the connection request, the connection between the NAS device and the WebSocket server is controlled.

4. The linkage management method for connecting NAS devices and servers according to claim 3, characterized in that, The device information includes the access gateway address and access token information of the NAS device, or the device information includes the certificate information of the NAS device; And, the step of creating a connection instance between the NAS device and the WebSocket server based on the device information of the NAS device includes: When the device information includes the access gateway address and access token information of the NAS device, the system performs automatic protocol conversion on the NAS device based on the access gateway address and access token information, detects the URL protocol of the NAS device, and obtains the protocol detection result; and constructs the initial URL parameters of the WebSocket server based on the protocol detection result; and creates a connection instance between the NAS device and the WebSocket server based on the initial URL parameters; or, When the device information includes the certificate information of the NAS device, an automatic certificate configuration process is triggered to parse the certificate information to create a certificate fixing verifier; and based on the certificate fixing verifier, a connection instance between the NAS device and the WebSocket server is created.

5. The linkage management method for connecting NAS devices and servers according to claim 4, characterized in that, The step of creating a connection instance between the NAS device and the WebSocket server based on the initial URL parameters includes: Based on the determined language configuration parameters of the NAS device, the initial URL parameters are configured to obtain the target URL parameters; Based on the target URL parameters, a connection instance between the NAS device and the WebSocket server is created; Furthermore, the language configuration parameters are determined in the following manner: Based on the business layer, the first language parameters of the NAS device are determined according to the device connection service; and the language configuration parameters of the NAS device are determined according to the first language parameters of the NAS device and the second language parameters of the obtained WebSocket server.

6. The linkage management method for connecting NAS devices and servers according to claim 5, characterized in that, The application is equipped with a heartbeat keep-alive and recovery mechanism, which is used to initiate a heartbeat detection operation to send a heartbeat message for the NAS device once every preset heartbeat interval, and save the heartbeat message of the NAS device. Furthermore, the method further includes: Obtain the connection result between the NAS device and the WebSocket server; When the connection between the NAS device and the WebSocket server is lost, the heartbeat detection operation is stopped. When the connection result between the NAS device and the WebSocket server indicates a successful connection, the heartbeat detection result of the application is obtained, and when the heartbeat detection result indicates that there is a heartbeat message for the NAS device, the heartbeat detection operation is restarted. When the connection between the NAS device and the WebSocket server is successfully reconnected, the heartbeat detection operation is resumed.

7. A linkage management device for connecting NAS devices and servers, characterized in that, The device is used in an electronic device with an application installed, and the electronic device is communicatively connected to a NAS device and accesses the NAS device through the application. The application is used to manage the communication connection of the NAS device, and the device includes: A connection module is used to control the NAS device to connect to a WebSocket server by listening to status change events of the NAS device, wherein the status change events include login status change events and / or connection status change events. The determination module is used to determine when the network status of the NAS device indicates that the NAS device has changed from a network unavailable state to a network available state, and to determine that the NAS device initiates a reconnection event that matches the WebSocket server. The determination module is used to determine whether the NAS device and the WebSocket server are reconnecting for the first time; The reconnection module is used to obtain a preset reconnection baseline delay when the determination module determines that the NAS device and the WebSocket server are reconnecting for the first time; and use the reconnection baseline delay as the reconnection delay time to perform the first reconnection attempt operation between the NAS device and the WebSocket server. The determining module is further configured to, when the judging module determines that the NAS device and the WebSocket server are not reconnecting for the first time, determine the reconnection delay time corresponding to the current reconnection number based on the exponential backoff algorithm, according to the reconnection baseline delay, the determined current reconnection number, and the preset maximum reconnection number; The reconnection module is further configured to perform the reconnection attempt operation between the NAS device and the WebSocket server based on the reconnection delay time corresponding to the current reconnection count; The judgment module is also used to determine whether the NAS device and the WebSocket server have successfully reconnected within the current number of reconnections; The reconnection module is further configured to, when the determination module determines that the NAS device and the WebSocket server fail to reconnect within the current reconnection count, perform the reconnection attempt operation on the NAS device and the WebSocket server again according to the maximum reconnection count, so that the last reconnection attempt operation is less than or equal to the maximum reconnection count, which is either the maximum reconnection count or the current reconnection count when the NAS device and the WebSocket server successfully reconnect.

8. An electronic device, characterized in that, The electronic device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the linkage management method for connecting NAS devices and servers as described in any one of claims 1-6.

9. A linkage management system for connecting NAS devices and servers, characterized in that, The system includes at least the linkage management device as described in claim 7, and a NAS device communicatively connected to the linkage management device; wherein the linkage management device performs a connection operation between the NAS device and the WebSocket server according to the linkage management method for connecting the NAS device and the server as described in any one of claims 1-6; or, The system includes at least the electronic device as described in claim 8, and a NAS device communicatively connected to the electronic device; wherein the electronic device performs a connection operation between the NAS device and the WebSocket server according to the linkage management method for NAS device and server connection as described in any one of claims 1-6.

10. A computer storage medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the linkage management method for connecting the NAS device and the server as described in any one of claims 1-6.