CN113098972A - Method and device for connecting with equipment, electronic equipment and storage medium - Google Patents

Method and device for connecting with equipment, electronic equipment and storage medium Download PDF

Info

Publication number
CN113098972A
CN113098972A CN202110391100.1A CN202110391100A CN113098972A CN 113098972 A CN113098972 A CN 113098972A CN 202110391100 A CN202110391100 A CN 202110391100A CN 113098972 A CN113098972 A CN 113098972A
Authority
CN
China
Prior art keywords
target
equipment
information
address information
determined
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110391100.1A
Other languages
Chinese (zh)
Other versions
CN113098972B (en
Inventor
黄金明
李秋林
金伟光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Shuke Haiyi Information Technology Co Ltd
Original Assignee
Jingdong Shuke Haiyi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Shuke Haiyi Information Technology Co Ltd filed Critical Jingdong Shuke Haiyi Information Technology Co Ltd
Priority to CN202110391100.1A priority Critical patent/CN113098972B/en
Publication of CN113098972A publication Critical patent/CN113098972A/en
Application granted granted Critical
Publication of CN113098972B publication Critical patent/CN113098972B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session

Abstract

The application relates to a method and a device for connecting with equipment, electronic equipment and a storage medium. The method comprises the following steps: receiving an access request of a target front end, wherein the access request carries target equipment information of target equipment to be accessed by the target front end and first address information of the target equipment; disconnecting the network connection with the target equipment according to the first address information; reestablishing network connection with the target equipment according to the second address information of the target equipment; the target device is accessed through the reestablished network connection. By the method in the embodiment, the network connection with the terminal equipment to be accessed can be disconnected, the network connection with the terminal equipment is reestablished based on the address information of the terminal equipment, and the stability of the network connection used by the terminal equipment can be ensured, so that the technical problem of unstable connection existing when the terminal equipment is connected is solved, and the technical effect of improving the stability of the connection with the terminal equipment is achieved.

Description

Method and device for connecting with equipment, electronic equipment and storage medium
Technical Field
The present application relates to the field of communication state control technologies, and in particular, to a method and an apparatus for connecting to a device, an electronic device, and a storage medium.
Background
In a scenario of testing a terminal device, etc., a connection end needs to be connected to one or more terminal devices for testing, for example, when an Android (Android) application is tested, the connection end (for example, a PC or a server) needs to be connected to one or more Android devices installed with a mobile phone application, in the current connection method, the connection end is connected to the Android devices in an adb connect ip: port (a command for establishing connection between an Android mobile phone and a proxy device), and the method has the following problems: the connection is unstable, although it appears that the connection is connected, and a sudden interruption occurs while the communication is performed.
In view of the technical problems in the related art, no effective solution is provided at present.
Disclosure of Invention
In order to solve the technical problem that connection is unstable when the terminal device is connected, the application provides a method and a device for connecting the terminal device, an electronic device and a storage medium.
In a first aspect, an embodiment of the present application provides a method for connecting to a device, including:
receiving an access request of a target front end, wherein the access request carries target equipment information of target equipment to be accessed by the target front end and first address information of the target equipment;
disconnecting the network connection with the target equipment according to the first address information;
reestablishing network connection with the target equipment according to the second address information of the target equipment;
accessing the target device over the reestablished network connection.
Optionally, as in the foregoing method, the disconnecting the network connection with the target device includes:
receiving an access request of the target front end, wherein the access request carries target equipment information of the target equipment and first address information of the target equipment;
and disconnecting the network connection with the target equipment according to the first address information.
Optionally, as in the foregoing method, the reestablishing a network connection with the target device according to the second address information of the target device includes:
and reestablishing network connection with the target equipment according to the first address information, wherein the second address information is the first address information.
Optionally, as in the foregoing method, before the reestablishing a network connection with the target device according to the second address information of the target device, the method further includes:
and querying a target back end to obtain the second address information corresponding to the target device information, wherein the target back end stores the target device information and the second address information which are set correspondingly in advance.
Optionally, as in the foregoing method, the method further comprises:
sending a heartbeat message to a device to be determined, wherein the currently cached state information of the device to be determined is used for representing that the device to be determined is in a connection state;
under the condition that the response of the equipment to be determined to the heartbeat message meets a preset reconnection condition, reestablishing the connection with the equipment to be determined;
generating target offline information under the condition that the connection with the equipment to be determined cannot be established, wherein the target offline information is used for representing that the equipment to be determined is in an offline state;
and sending the target offline information to a target rear end so that the target rear end marks the equipment to be determined as offline equipment according to the target offline information.
Optionally, as in the foregoing method, the preset reconnection condition includes: and the equipment to be determined continuously does not respond to the first preset number of heartbeat messages.
Optionally, as in the foregoing method, the preset reconnection condition includes: and the equipment to be determined does not respond to at least a third preset number of heartbeat messages in the second preset number of heartbeat messages.
Optionally, as in the foregoing method, the method further comprises:
receiving a connection request sent by a device to be connected, wherein the connection request carries current address information of the device to be connected;
establishing network connection with the equipment to be connected according to the current address information;
acquiring equipment information of the equipment to be connected;
and sending the equipment information and the current address information of the equipment to be connected to a target back end for storage.
In a second aspect, an embodiment of the present application provides an apparatus connected to a device, including:
a receiving module, configured to receive an access request of a target front end, where the access request carries target device information of a target device to be accessed by the target front end and first address information of the target device;
the disconnection module is used for disconnecting the network connection with the target equipment according to the first address information;
the reconnection module is used for reestablishing network connection with the target equipment according to the second address information of the target equipment;
and the access module is used for accessing the target equipment through the reestablished network connection.
Optionally, as in the foregoing apparatus, the disconnection module includes:
the receiving submodule is used for receiving an access request of the target front end, wherein the access request carries target equipment information of the target equipment and first address information of the target equipment;
and the disconnection submodule is used for disconnecting the network connection with the target equipment according to the first address information.
Optionally, as in the foregoing apparatus, the reconnection module is configured to:
and reestablishing network connection with the target equipment according to the first address information, wherein the second address information is the first address information.
Optionally, the apparatus as aforementioned, further includes a query module:
the query module is configured to query a target back end to obtain the second address information corresponding to the target device information, where the target back end stores the target device information and the second address information that are set correspondingly in advance.
Optionally, the apparatus as aforementioned, further comprising:
the device comprises a heartbeat message sending module, a heartbeat message sending module and a heartbeat message sending module, wherein the current cached state information of the device to be determined is used for representing that the device to be determined is in a connection state;
the judging module is used for reestablishing the connection with the equipment to be determined under the condition that the response of the equipment to be determined to the heartbeat message meets a preset reconnection condition;
the offline information module is used for generating target offline information under the condition that the connection with the equipment to be determined cannot be established, wherein the target offline information is used for representing that the equipment to be determined is in an offline state;
and the offline information sending module is used for sending the target offline information to a target rear end so that the target rear end marks the equipment to be determined as offline equipment according to the target offline information.
Optionally, in the foregoing apparatus, the preset reconnection condition includes: and the equipment to be determined continuously does not respond to the first preset number of heartbeat messages.
Optionally, in the foregoing apparatus, the preset reconnection condition includes: and the equipment to be determined does not respond to at least a third preset number of heartbeat messages in the second preset number of heartbeat messages.
In a third aspect, an embodiment of the present application provides an electronic device, including: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor, when executing the computer program, is configured to implement the method according to any of the preceding claims.
In a fourth aspect, the present application provides a computer-readable storage medium, which includes a stored program, where the program is executed to perform the method according to any one of the preceding claims.
The embodiment of the application provides a method and a device for connecting with equipment, electronic equipment and a storage medium. The method comprises the following steps: disconnecting network connection with target equipment, wherein the target equipment is equipment to be accessed by a target front end; reestablishing network connection with the target equipment according to the second address information of the target equipment; accessing the target device over the reestablished network connection. By the method in the embodiment, the network connection with the terminal equipment to be accessed can be disconnected, the network connection with the terminal equipment is reestablished based on the address information of the terminal equipment, and the stability of the network connection used by the terminal equipment can be ensured, so that the technical problem of unstable connection existing when the terminal equipment is connected is solved, and the technical effect of improving the stability of the connection with the terminal equipment can be achieved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of a method for interfacing with a device according to an embodiment of the present disclosure;
fig. 2 is a flowchart of a method for interfacing with a device according to another embodiment of the present application;
fig. 3 is a block diagram of a device connection system according to an embodiment of the present application;
fig. 4 is a block diagram of an apparatus connected to a device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Under the scenes of testing terminal equipment and the like, the connecting end is required to be connected to one or more terminals for testing.
Taking a terminal as an android device as an example, in the device connection system shown in fig. 3, when a tester performs a test by controlling a plurality of android devices 2 at a test front end 4 (for example, a PC end), a test method may be:
the testing front end 4 accesses the server end 3 to obtain the device information and address information of the accessible android device based on the http protocol, the testing front end 4 establishes a webSocket communication (the webSocket communication is a protocol for performing full duplex communication on a single TCP connection) with the android device connection end 1 (for example, a PC or a server with an agent installed therein), the android device connection end 1 accesses the agent end on the android device corresponding to the device information according to the device information and address information of the android device 2 to be accessed, which are sent by the testing front end 4, the android device connection end 1 and the android device 2 can be subjected to socket communication in advance through a serial port, a USB or a wireless mode (for example, WiFi or a mobile network) connection, then a tester can send a request or a command to the android device by using a testing tool, and after the android device 2 receives the command or the request, and the agent on the android device 2 analyzes the commands, and then the agent on the android device 2 issues the analyzed commands to the commands which can be identified by each functional module of the mobile phone, and calls the corresponding functional module to simulate operation.
After the operation is completed, the android device 2 can return some target information, the agent on the android device 2 can grab the target information, then the target information is sent to the server end 3 based on the http protocol through the android device connecting end 1 in sequence, so that the testing front end 4 obtains the target information through accessing the server end 3, or the android device connecting end 1 directly sends the target information back to the testing front end 4 through websocket communication, and thus, a complete mobile phone automatic test is completed. Further, the android devices can be controlled by means of MMI _ command (at command), i.e., each android device is provided with a responsive interface.
When a target device (i.e., a certain android device 2) does not receive an access from a target front end (i.e., a certain test front end 4) for a long time, the target front end cannot access the target device to obtain corresponding device information or perform device operation due to the problem that a network connection established between the target device and the android device connection end through a command adb connect ip: port is unstable or closed.
In order to overcome the above problem, fig. 1 provides a method for connecting to a device according to an embodiment of the present application, including the following steps S1 to S4:
step S1, an access request of the target front end is received, where the access request carries target device information of a target device to be accessed by the target front end and first address information of the target device.
The method for connecting to a device in this embodiment may be applied to a scenario in which the device connection end accesses the terminal device, as shown in fig. 3, the method for connecting to a device may be executed by the device connection end (for example, a PC end installed with an agent).
The device connection end can determine that the device to be accessed by the target front end currently is the target device. The target device can be an android device which is connected with the device connection end through an adb connect ip execution command, and then an agent at the device connection end can access the android device.
And the device connecting end can disconnect the network connection with the target device when the target front end is determined to need to access the target device. For example, the device connection end may disconnect the connection between the interfaces corresponding to the target device according to the address information of the target device, so as to achieve the purpose of disconnecting the network connection with the target device.
The target device information may include, but is not limited to: the mac address of the target device, the model of the device, the brand of the device, the system version number, the device number and the like are used for representing information of each attribute of the target device.
The device connection may receive an access request from the target front-end, where the access request may be a request sent by the target front-end when accessing the target device. The access request may carry destination device information and second address information of the destination device. The target device information and the second address information may be pulled by the target front end from the target back end.
The target backend may store device information of each device and address information (e.g., IP address and port number) in advance. For the target device, the target backend stores target device information of the target device and the second address information.
When a user needs to access information on a target device through a target front end, the target front end may first pull information required for accessing the target device from a target back end, which may include but is not limited to: address information (e.g., IP address and port number) of a device connection end connected to the destination device, destination device information of the destination device, and second address information.
The target front end can establish connection with the equipment connecting end by using address information of the equipment connecting end, for example, the target front end establishes connection with the equipment connecting end through websocket; generating an access request according to the pulled target equipment information and the second address information; and sends the access request to the device connection terminal through the connection with the device connection terminal.
Further, the step S1 of disconnecting the network connection with the target device may be executed before the target front end starts to access the target device each time.
And step S2, disconnecting the network connection with the target device according to the first address information.
After the device connecting end acquires the access request, analyzing to obtain first address information in the access request, and then enabling the agent at the device connecting end to disconnect the network connection between the target devices corresponding to the first address information according to the first address information; furthermore, when the address information of the target front end is changed, when disconnection is performed, according to the disconnection failure information, it can be determined that the device connection end is disconnected from the target front end.
In summary, according to the method in this embodiment, the connection with the target device can be quickly disconnected based on the request of the target front end, so that an unstable connection state with the target front end can be disconnected, and the network connection stability can be improved by reconnecting with the target device at a later stage.
Step S3, reestablishing the network connection with the target device according to the second address information of the target device.
The second address information may include, but is not limited to: IP address information and port number of the target device.
Each target device has second address information uniquely corresponding to the target device; when the IP address and the port number of the target equipment are not changed, the equipment connecting end can reestablish network connection with the target equipment according to the IP address and the port number of the target equipment; when the IP address and the port number of the target device change, the device connection end cannot establish a network connection with the target device based on the original second address information.
In step S4, the target device is accessed through the reestablished network connection.
After the network connection between the device connection end and the target device is established, the agent of the device connection end can access the target device, so that the target front end can also access the target device through the device connection end.
By the method in the embodiment, before the target device is accessed, the network connection between the device connecting end and the target device is disconnected, and then the network connection between the device connecting end and the target device is established, so that the situation that the network connection between the device connecting end and the target device is unstable or closed due to the fact that the target device is not accessed through the device connecting end for a long time before disconnection can be avoided, and the target device can be stably accessed through the device connecting end.
In some embodiments, as the method mentioned above, the step S3 of reestablishing the network connection with the target device according to the second address information of the target device includes the following steps S31:
step S31, reestablishing the network connection with the target device according to the first address information, wherein the second address information is the first address information.
As can be seen from step S11 in the foregoing embodiment, the first address information is address information corresponding to the target device carried in the access request of the target front end, and therefore, when the device connection end does not change the address information after disconnecting the network connection with the target device, the network connection with the target device may be reestablished based on the first address information. The first address information may be read from a local side for storing the access request.
In an optional implementation manner of this embodiment, a storage location for storing or caching the access request may be disposed in the device connection end, and after receiving the access request, the access request may be stored in the storage location; and after the network connection with the target device is disconnected, the access request is read from the storage position again, and the first address information in the access request is obtained.
In another optional implementation manner of this embodiment, historical device information and historical address information of a historical device that has executed disconnection may also be recorded, and stored in a related log according to a time sequence; and then, inquiring the log to obtain first address information of the target device which has recently executed the disconnection operation and is not connected.
After the agent of the device connection end acquires the first address information, the network connection with the target device can be reestablished according to the first address information.
By the method in the embodiment, the first address information of the target device needing to be reconnected can be quickly inquired and obtained at the local end, so that the speed of establishing the connection with the target device is improved, the target front end can access the target device more quickly, and the user experience is improved.
In some embodiments, as the method mentioned above, the step S3 of reestablishing the network connection with the target device according to the second address information of the target device includes the following steps S32:
step S32, obtaining second address information corresponding to the target device information by querying the target backend, where the target backend stores the target device information and the second address information that are set correspondingly in advance.
The second address information is address information which is stored on the back end of the target and corresponds to the target equipment information; and the target back end stores the equipment information and the address information in a one-to-one correspondence manner according to the equipment information and the address information corresponding to each equipment.
Therefore, the agent connected to the device can query the target back end for the corresponding second address information based on the target device information.
Furthermore, the address of the target device is changed; and after the address of the target device is changed, the target device can transmit the address information corresponding to the changed address to the target backend, so that the target backend can update the second address information in real time according to the latest address information. Furthermore, when the target back end cannot establish network connection with the target equipment through the first address information of the local end, the target back end can inquire the target back end, and try to establish connection with the target equipment again according to the inquired second address information; therefore, when the address information of the target device is updated, the network connection with the target device can still be established.
On the other hand, before the network connection between the device connection terminal and the target device is disconnected, the connection state between the target device and the device connection terminal cached by the target front end is most likely not up-to-date; therefore, the connection state of the cache indicates that the connection end of the target device and the device is connected, but actually, the connection end of the target device and the device is disconnected, that is, a false connection state exists; therefore, in this case, if the test front end needs to access the target device, the access may not be performed.
For example: when the false connection problem occurs between the device connection end and the device, due to some reasons, such as shutdown of the device and unstable network, the connection is finally disconnected, the connection is truly disconnected due to the change of the device IP, and the connection cannot be reestablished, the agent of the device connection end needs to be detected in time and reported to the server end (i.e., the target back end).
As shown in fig. 2, in some embodiments, to solve the above technical problem, the method further includes steps S5 to S8 as follows:
step S5, sending a heartbeat message to the device to be determined, where the currently cached state information of the device to be determined is used to represent that the device to be determined is in a connected state.
The method in this embodiment may be applied to a scenario in which the device connection end tests the connection state of the terminal device, and the test method may be executed by the device connection end (for example, a PC end installed with an agent).
Specifically, the device to be determined may be any device that needs to perform the determination of the status information and is connected to the device connection terminal.
The heartbeat message is generated by the agent of the device connection end and is used for sending the message to the device end to be determined, and the agent of the device connection end can determine whether and when the network connection with the device end to be determined is interrupted according to the feedback of the device end to be determined.
The agent of the device connection end can determine the address information of each device to be determined, and then sends heartbeat messages to the devices to be determined according to the address information.
And step S6, reestablishing the connection with the device to be determined under the condition that the response of the device to be determined to the heartbeat message meets the preset reconnection condition.
Specifically, the response of the device to be determined to the message may be, under normal circumstances: feeding back a confirmation message to an agent at the connection end of the equipment when the equipment to be determined receives a heartbeat message; therefore, the condition that the response of the device to be determined to the heartbeat message satisfies the preset reconnection condition may be that the acknowledgement message of the device to be determined to the heartbeat message is not received, or the number of the received acknowledgement messages of the device to be determined to the heartbeat message is far less than the number of the sent heartbeat messages.
In this case, it is described that the network connection between the device connection end and the device to be determined is unstable, or the network is disconnected, and since the heartbeat message is actively sent by the agent at the device connection end, it is caused that the heartbeat message can determine the address information of the device to be determined in which the abnormality occurs; therefore, the connection with the equipment to be determined can be reestablished according to the address information of the equipment to be determined with the abnormality.
In some embodiments, as in the method above, the predetermined reconnection condition comprises one of:
the method comprises the following steps that 1, equipment to be determined continuously does not respond to a first preset number of heartbeat messages; the first preset number may be preset number information.
For example, when the first preset number is 10, the condition 1 is: the device to be determined does not continuously feed back confirmation messages for the 10 heartbeat messages.
Condition 2, the device to be determined does not respond to at least a third preset number of heartbeat messages in the second preset number of heartbeat messages; the second preset number and the third preset number may be preset number information, and the third preset number is less than or equal to the second preset number.
For example, when the second predetermined number is 10 and the third predetermined number is 5, the condition 2 is: the device to be determined does not feed back acknowledgement messages for at least 5 of the 10 heartbeat messages.
Step S7, in a case that the connection with the device to be determined cannot be established, generating target offline information, where the target offline information is used to represent that the device to be determined is in an offline state.
Specifically, the target offline information may include, but is not limited to: the device information and the address information of the device to be determined and the offline state information used for indicating that the device to be determined is in the offline state.
When the IP address or port of the device to be determined is changed, which results in that the network connection with the device to be determined cannot be established according to step S6, target offline information representing that the device to be determined cannot be connected and is in an offline state is generated.
Step S8, sending the target offline information to the target back end, so that the target back end marks the device to be determined as an offline device according to the target offline information.
Specifically, since the network connection is pre-established between the device connection end and the target back end, the agent of the device connection end can send the target offline information to the target back end according to the network connection between the device connection end and the target back end, and after the target back end receives the target offline information, the device information and the offline state information of the device to be determined in the target offline information can be obtained through analysis, and then the device to be determined is marked as the offline device according to the device information and the offline state information.
After the target back end marks the device to be determined as the offline device, and the target front end synchronizes the data of the target back end, the device to be determined can be determined to be in the offline state, and further, the device to be determined can be prevented from being accessed.
By the method in the embodiment, whether reconnection is performed can be judged in real time according to the response of the heartbeat message of the equipment to be determined so as to ensure the stability of network connection in real time; meanwhile, the condition that the access of the test front end to the target equipment is failed through the equipment connecting end due to the false connection state between the target equipment and the equipment connecting end can be avoided.
In some embodiments, as in the previous method, the method further comprises steps S91 to S94 as follows:
step S91, receiving a connection request sent by the device to be connected, where the connection request carries current address information of the device to be connected.
The method in this embodiment may be applied to a scenario in which the device connection end and the terminal device initially establish a connection, and the method of establishing a connection may be executed by the device connection end (for example, a PC end installed with an agent).
Specifically, the device to be connected may be a device that needs to establish a network connection with the device connection end and receive access from the target front end.
The connection request may include the current address information of the device to be connected and the related information of the agent for requesting to connect to the device connection terminal.
Further, the device to be connected may send a connection request to the target back end in advance, so that the target back end receives the request according to the agent at the connection end of the connection request management and control device.
And step S92, establishing network connection with the target device according to the current address information.
Specifically, after the current address information in the connection request is obtained, a command adb connect ip can be executed according to the current address information, wherein the port establishes network connection between the device connection end and the device to be connected.
Step S93, device information of the device to be connected is acquired.
Specifically, after the network connection between the device connection end and the device to be connected is established, the device information of the device to be connected may be acquired, including but not limited to: mac address, model of equipment, brand of equipment, system version number and the like.
And step S94, sending the device information and the current address information of the device to be connected to the target back end for storage.
Specifically, after the agent of the device connection end acquires the device information, the device information and the current address information can be sent to the target back end for storage based on network connection with the target back end, and when any front end capable of accessing the target back end is accessed, the device information and the current address information can be acquired from the target back end and displayed.
For example: when the android terminal (i.e. the device to be connected) is connected with the device through a certain network (e.g. a WiFi network) and is in the same network environment, an HTTP request can be made to a server (i.e. a target back end) to request to connect to the device connection end, and after the HTTP request is received by the server, the device connection end can be controlled to conduct active search, and after the device to be connected is searched, connection with the device to be connected is established. Then, the device to be connected can send a request to the agent of the device connection end through WiFi, the agent of the device connection end can obtain the IP address and the port of the mobile end, a command adb connect IP can be executed, the port can connect the android terminal with the device connection end, the device connection end can obtain specific information of the device after connection is established, such as the mac address, the model of the device, the brand of the device, the system version number and other information, and then the agent of the device connection end can send the information to the server end. When the target front end receives the user access, the target front end can obtain the information from the server end and display the information.
By the method in the embodiment, the device information and the current address information of the device to be connected, which is accessed to the device connection end for the first time, can be acquired, and after the device information and the current address information are transmitted to the target back end, when any front end connected with the target back end is accessed, the device information and the current address information can be acquired from the target back end and displayed, so that a user can select the device to be accessed according to the displayed information.
As shown in fig. 4, according to an embodiment of another aspect of the present application, there is also provided an apparatus connected to a device, including:
a receiving module 11, configured to receive an access request of a target front end, where the access request carries target device information of a target device to be accessed by the target front end and first address information of the target device;
a disconnection module 12, configured to disconnect a network connection with the target device according to the first address information;
a reconnection module 13, configured to reestablish a network connection with the target device according to the second address information of the target device;
and an accessing module 14 for accessing the target device through the reestablished network connection.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
In some embodiments, such as the aforementioned apparatus, the reconnect module 13 is configured to:
and reestablishing the network connection with the target equipment according to the first address information, wherein the second address information is the first address information.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
In some embodiments, the apparatus as aforementioned, further comprising a query module:
and the query module is used for querying the target back end to obtain second address information corresponding to the target equipment information, wherein the target back end stores the target equipment information and the second address information which are correspondingly set in advance.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
In some embodiments, the apparatus as in the previous paragraph, further comprising:
the heartbeat message sending module is used for sending a heartbeat message to the equipment to be determined, wherein the currently cached state information of the equipment to be determined is used for representing that the equipment to be determined is in a connection state;
the judging module is used for reestablishing the connection with the equipment to be determined under the condition that the response of the equipment to be determined to the heartbeat message meets the preset reconnection condition;
the device comprises an offline information module, a data processing module and a data processing module, wherein the offline information module is used for generating target offline information under the condition that the connection with the device to be determined cannot be established, and the target offline information is used for representing that the device to be determined is in an offline state;
and the offline information sending module is used for sending the target offline information to the target rear end so that the target rear end marks the equipment to be determined as offline equipment according to the target offline information.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
In some embodiments, such as the aforementioned apparatus, the predetermined reconnection condition comprises one of: and the equipment to be determined continuously does not respond to the heartbeat messages with the first preset number, and the equipment to be determined does not respond to at least a third preset number of heartbeat messages in the heartbeat messages with the second preset number.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
In some embodiments, the apparatus as described above, further comprising a primary connection module configured to:
receiving a connection request sent by equipment to be connected, wherein the connection request carries current address information of the equipment to be connected;
establishing network connection with the equipment to be connected according to the current address information;
acquiring equipment information of equipment to be connected;
and sending the equipment information and the current address information of the equipment to be connected to the target back end for storage.
Specifically, the specific process of implementing the functions of each module in the apparatus according to the embodiment of the present invention may refer to the related description in the method embodiment, and is not described herein again.
According to another embodiment of the present application, there is also provided an electronic apparatus including: as shown in fig. 5, the electronic device may include: the system comprises a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 complete communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501 is configured to implement the steps of the above-described method embodiments when executing the program stored in the memory 1503.
The bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
The embodiment of the present application further provides a storage medium, where the storage medium includes a stored program, and the program executes the method steps of the foregoing method embodiment when running.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (15)

1. A method of interfacing with a device, comprising:
receiving an access request of a target front end, wherein the access request carries target equipment information of target equipment to be accessed by the target front end and first address information of the target equipment;
disconnecting the network connection with the target equipment according to the first address information;
reestablishing network connection with the target equipment according to the second address information of the target equipment;
accessing the target device over the reestablished network connection.
2. The method of claim 1, wherein the reestablishing the network connection with the target device according to the second address information of the target device comprises:
and reestablishing network connection with the target equipment according to the first address information, wherein the second address information is the first address information.
3. The method of claim 1, wherein before the reestablishing the network connection with the target device according to the second address information of the target device, the method further comprises:
and querying a target back end to obtain the second address information corresponding to the target device information, wherein the target back end stores the target device information and the second address information which are set correspondingly in advance.
4. The method of claim 1, further comprising:
sending a heartbeat message to a device to be determined, wherein the currently cached state information of the device to be determined is used for representing that the device to be determined is in a connection state;
under the condition that the response of the equipment to be determined to the heartbeat message meets a preset reconnection condition, reestablishing the connection with the equipment to be determined;
generating target offline information under the condition that the connection with the equipment to be determined cannot be established, wherein the target offline information is used for representing that the equipment to be determined is in an offline state;
and sending the target offline information to a target rear end so that the target rear end marks the equipment to be determined as offline equipment according to the target offline information.
5. The method of claim 4, wherein the preset reconnect condition comprises: and the equipment to be determined continuously does not respond to the first preset number of heartbeat messages.
6. The method of claim 4, wherein the preset reconnect condition comprises: and the equipment to be determined does not respond to at least a third preset number of heartbeat messages in the second preset number of heartbeat messages.
7. The method according to any one of claims 1 to 6, further comprising:
receiving a connection request sent by a device to be connected, wherein the connection request carries current address information of the device to be connected;
establishing network connection with the equipment to be connected according to the current address information;
acquiring equipment information of the equipment to be connected;
and sending the equipment information of the equipment to be connected and the current address information to a target back end for storage.
8. An apparatus for interfacing with a device, comprising:
a receiving module, configured to receive an access request of a target front end, where the access request carries target device information of a target device to be accessed by the target front end and first address information of the target device;
the disconnection module is used for disconnecting the network connection with the target equipment according to the first address information;
the reconnection module is used for reestablishing network connection with the target equipment according to the second address information of the target equipment;
and the access module is used for accessing the target equipment through the reestablished network connection.
9. The apparatus of claim 8, wherein the reconnect module is configured to:
and reestablishing network connection with the target equipment according to the first address information, wherein the second address information is the first address information.
10. The apparatus of claim 8, further comprising a query module:
the query module is configured to query a target back end to obtain the second address information corresponding to the target device information, where the target back end stores the target device information and the second address information that are set correspondingly in advance.
11. The apparatus of claim 8, further comprising:
the device comprises a heartbeat message sending module, a heartbeat message sending module and a heartbeat message sending module, wherein the current cached state information of the device to be determined is used for representing that the device to be determined is in a connection state;
the judging module is used for reestablishing the connection with the equipment to be determined under the condition that the response of the equipment to be determined to the heartbeat message meets a preset reconnection condition;
the offline information module is used for generating target offline information under the condition that the connection with the equipment to be determined cannot be established, wherein the target offline information is used for representing that the equipment to be determined is in an offline state;
and the offline information sending module is used for sending the target offline information to a target rear end so that the target rear end marks the equipment to be determined as offline equipment according to the target offline information.
12. The apparatus of claim 11, wherein the preset reconnect condition comprises: and the equipment to be determined continuously does not respond to the first preset number of heartbeat messages.
13. The apparatus of claim 11, wherein the preset reconnect condition comprises: and the equipment to be determined does not respond to at least a third preset number of heartbeat messages in the second preset number of heartbeat messages.
14. An electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor, when executing the computer program, implementing the method of any of claims 1-7.
15. A computer-readable storage medium, characterized in that the storage medium comprises a stored program, wherein the program when executed performs the method of any of the preceding claims 1-7.
CN202110391100.1A 2021-04-12 2021-04-12 Method and device for connecting with equipment, electronic equipment and storage medium Active CN113098972B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110391100.1A CN113098972B (en) 2021-04-12 2021-04-12 Method and device for connecting with equipment, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110391100.1A CN113098972B (en) 2021-04-12 2021-04-12 Method and device for connecting with equipment, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113098972A true CN113098972A (en) 2021-07-09
CN113098972B CN113098972B (en) 2023-01-31

Family

ID=76676327

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110391100.1A Active CN113098972B (en) 2021-04-12 2021-04-12 Method and device for connecting with equipment, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113098972B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060031488A1 (en) * 2000-07-11 2006-02-09 Scorpion Controls, Inc. Automatic determination of correct IP address for network-connected devices
EP2955946A1 (en) * 2014-06-11 2015-12-16 Samsung Electronics Co., Ltd Electronic device and network connection method of electronic device
CN105933469A (en) * 2016-06-17 2016-09-07 北京京东尚科信息技术有限公司 Network access method and device for intelligent equipment and intelligent equipment
CN106067906A (en) * 2016-05-25 2016-11-02 浙江大华技术股份有限公司 A kind of method of reconnect and monitoring device
US20170366983A1 (en) * 2016-06-15 2017-12-21 Time Warner Cable Enterprises Llc Apparatus and methods for monitoring and diagnosing a wireless network
CN107852416A (en) * 2015-08-26 2018-03-27 微软技术许可有限责任公司 The life cycle of monitoring computer network connection
CN108430116A (en) * 2018-03-02 2018-08-21 杭州朗和科技有限公司 Suspension reconnection method, medium, device and computing device
CN109413612A (en) * 2018-10-22 2019-03-01 深圳市元征科技股份有限公司 A kind of communication connection method for building up and equipment
CN111225020A (en) * 2019-11-07 2020-06-02 苏州浪潮智能科技有限公司 User mode network file system dual-stack access method, device and equipment
CN111510492A (en) * 2020-04-15 2020-08-07 矩阵元技术(深圳)有限公司 Data processing method, device, equipment and system for realizing disconnection reconnection

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060031488A1 (en) * 2000-07-11 2006-02-09 Scorpion Controls, Inc. Automatic determination of correct IP address for network-connected devices
EP2955946A1 (en) * 2014-06-11 2015-12-16 Samsung Electronics Co., Ltd Electronic device and network connection method of electronic device
CN107852416A (en) * 2015-08-26 2018-03-27 微软技术许可有限责任公司 The life cycle of monitoring computer network connection
CN106067906A (en) * 2016-05-25 2016-11-02 浙江大华技术股份有限公司 A kind of method of reconnect and monitoring device
US20170366983A1 (en) * 2016-06-15 2017-12-21 Time Warner Cable Enterprises Llc Apparatus and methods for monitoring and diagnosing a wireless network
CN105933469A (en) * 2016-06-17 2016-09-07 北京京东尚科信息技术有限公司 Network access method and device for intelligent equipment and intelligent equipment
CN108430116A (en) * 2018-03-02 2018-08-21 杭州朗和科技有限公司 Suspension reconnection method, medium, device and computing device
CN109413612A (en) * 2018-10-22 2019-03-01 深圳市元征科技股份有限公司 A kind of communication connection method for building up and equipment
CN111225020A (en) * 2019-11-07 2020-06-02 苏州浪潮智能科技有限公司 User mode network file system dual-stack access method, device and equipment
CN111510492A (en) * 2020-04-15 2020-08-07 矩阵元技术(深圳)有限公司 Data processing method, device, equipment and system for realizing disconnection reconnection

Also Published As

Publication number Publication date
CN113098972B (en) 2023-01-31

Similar Documents

Publication Publication Date Title
EP3876607A1 (en) Intelligent scheduling method, terminal device, edge node cluster and intelligent scheduling system
CN109391655B (en) Service gray level publishing method, device and system and storage medium
CN109495306B (en) Method and equipment for expanding capacity of service network
CN111711533B (en) Fault diagnosis method, fault diagnosis device, electronic device and storage medium
WO2022127504A1 (en) Network element management method and apparatus, and storage medium
CN104301140A (en) Service request responding method, device and system
CN112714426B (en) Intelligent upgrading method and device of Bluetooth equipment, electronic equipment and medium
CN109586987B (en) Method and device for testing equipment in cloud storage system
CN111159269B (en) Data processing method, device and system
CN107360036B (en) Network fault positioning method, terminal and server
CN111541596A (en) Relay response automatic numbering method, device, equipment and storage medium
CN113098972B (en) Method and device for connecting with equipment, electronic equipment and storage medium
JP5610654B2 (en) Apparatus for providing terminal management package and method for receiving terminal management package
CN112202643B (en) Network detection method, device, test host and storage medium
CN112491810B (en) Data connection method and mobile terminal
CN108307542B (en) Method and device for realizing reconnection of Bluetooth peripheral equipment by intelligent television during Bluetooth adapter replacement
CN113411228A (en) Network condition determining method and server
CN112800604A (en) Simulation method, device, equipment and storage medium applied to industrial detection
CN111131528B (en) Equipment network domain determining method, server and terminal
CN114189424B (en) Intelligent device control method, intelligent device control device, electronic device, medium and program product
CN116827932B (en) Multi-server remote control method and device, electronic equipment and storage medium
US11323606B2 (en) Image capturing apparatus that stores information indicating whether communication with lens is possible, control method, and storage medium
TW202002579A (en) The control system and the method for the data fetching of the LAN in the IoT
CN115208791B (en) Method for testing functions of Internet of things equipment
US20210352765A1 (en) Communication method, apparatus, and system, storage medium, and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Information Technology Co.,Ltd.

Address before: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant