CN113411367B - Method, device, equipment, system and storage medium for establishing connection of monitoring equipment - Google Patents

Method, device, equipment, system and storage medium for establishing connection of monitoring equipment Download PDF

Info

Publication number
CN113411367B
CN113411367B CN202010186648.8A CN202010186648A CN113411367B CN 113411367 B CN113411367 B CN 113411367B CN 202010186648 A CN202010186648 A CN 202010186648A CN 113411367 B CN113411367 B CN 113411367B
Authority
CN
China
Prior art keywords
port
router
client
request
connection
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.)
Active
Application number
CN202010186648.8A
Other languages
Chinese (zh)
Other versions
CN113411367A (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.)
Zhejiang Uniview Technologies Co Ltd
Original Assignee
Zhejiang Uniview Technologies 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 Zhejiang Uniview Technologies Co Ltd filed Critical Zhejiang Uniview Technologies Co Ltd
Priority to CN202010186648.8A priority Critical patent/CN113411367B/en
Publication of CN113411367A publication Critical patent/CN113411367A/en
Application granted granted Critical
Publication of CN113411367B publication Critical patent/CN113411367B/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
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/63Routing a service request depending on the request content or context

Abstract

The invention discloses a method, a device, equipment, a system and a computer readable storage medium for establishing connection of monitoring equipment; in the scheme, when the client is connected with the monitoring equipment, if the monitoring equipment does not receive the next request sent by the client after returning a request response to the client through the original port, the monitoring equipment replaces the original port with the standby port, and automatically modifies the mapping relation between the router and the monitoring equipment, so that the response request can be sent to the client through the modified mapping relation, and the connection between the client and the monitoring equipment is successfully established, and thus, when the client acquires the live and playback data of the monitoring equipment, the phenomenon of black screen caused by the forbidden port of the router can be avoided; moreover, the mode of canceling the original port mapping relation and reserving the internal port of the router can ensure that the networking of the NAT is normal, and the problem of abnormal cutoff caused by the change of the internal port can not occur.

Description

Method, device, equipment, system and storage medium for establishing connection of monitoring equipment
Technical Field
The present invention relates to the field of data interaction technologies, and in particular, to a method, an apparatus, a device, a system, and a computer-readable storage medium for establishing a connection for a monitoring device.
Background
Currently, in the monitoring field, a common standard networking is that NVR (Network Video Recorder) and IPC (IP CAMERA) are mapped to an external Network through a router port under a local area Network, and audio and Video stream transmission is performed through RTSP (Real Time Streaming Protocol) for a user to remotely access and use, see fig. 1, which is a schematic diagram of a common monitoring networking in the prior art, and as can be seen in fig. 1, the NVR and the IPC perform audio and Video interaction with a cloud service website of a wide area Network and a mobile phone client through a router. However, at present, some common routers automatically disable NAT (Network Address Translation) interaction of some ports of devices in the NAT, for example, some routers automatically disable NAT interaction of 554 ports of devices in the NAT, at this time, RTSP cannot pass through NAT transmission, when a user views the live and playback of a camera and a video recorder, a black screen phenomenon occurs, the user cannot use the devices normally, and the user cannot know that the problem is caused by the router disabling the ports, and cannot know how to avoid the problem.
Disclosure of Invention
The invention aims to provide a method, a device, equipment, a system and a computer readable storage medium for establishing connection of monitoring equipment, so as to avoid the problem that data transmission cannot be carried out through a port due to the fact that the port is forbidden by a router.
In order to achieve the above object, the present invention provides a method for establishing a connection by a monitoring device, including:
receiving a connection request forwarded by a router through an internal port, wherein the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
sending a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
if no other request sent by the client is received within a first preset time length after the response request is sent, canceling the mapping relation between the internal port and the external port at the router, and establishing the mapping relation between the standby port and the external port;
and sending the response request to the router through the standby port, so that the router forwards the response request to the client through the external port, and thus, the connection between the monitoring device and the client is established.
Wherein, the receiving the connection request forwarded by the router through the internal port includes:
and receiving an OPTIONS request for establishing RTSP connection forwarded by the router through the internal port.
Wherein, canceling the mapping relationship between the internal port and the external port and establishing the mapping relationship between the standby port and the external port at the router includes:
sending a mapping relation canceling instruction to the router, wherein the mapping relation canceling instruction is used for canceling the mapping relation between the internal port and the external port;
and if receiving prompt information that the mapping relation cancellation sent by the router is successful, sending a mapping relation establishing instruction to the router, wherein the mapping relation establishing instruction is used for establishing the mapping relation between the standby port and the external port.
Wherein sending the response request to the router through the backup port comprises:
and if receiving prompt information that the mapping relation is successfully established and sent by the router, sending the response request to the router through the standby port.
If no other requests sent by the client are received within a first preset time length after the response request is sent, the method further comprises the following steps:
sending a keep-alive command to the client through the router;
judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length;
if yes, the step of canceling the mapping relation between the internal port and the external port and establishing the mapping relation between the standby port and the external port in the router is executed.
In order to achieve the above object, the present invention further provides an apparatus for establishing connection between monitoring devices, including:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a connection request forwarded by a router through an internal port, the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
a first sending module, configured to send a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
a port replacement module, configured to cancel, at the router, a mapping relationship between the internal port and the external port and establish a mapping relationship between the standby port and the external port when the response request is sent within a first predetermined time period after the response request is sent and other requests sent by the client are not received;
and the second sending module is used for sending the response request to the router through the standby port so that the router forwards the response request to the client through the external port, and thus the connection between the monitoring device and the client is established.
Wherein, this device still includes:
a third sending module, configured to send a keep-alive command to the client through the router;
the judging module is used for judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length;
the port replacement module is configured to cancel, at the router, the mapping relationship between the internal port and the external port and establish the mapping relationship between the standby port and the external port when a keep-alive response command forwarded by the client through the router is received within a second predetermined time period.
To achieve the above object, the present invention further provides an electronic device comprising:
a memory for storing a computer program;
a processor for implementing the steps of the method for establishing a connection with a monitoring device when executing the computer program.
To achieve the above object, the present invention further provides a connection establishment system, comprising: client, router, and above-mentioned electronic equipment.
To achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the method for establishing a connection by a monitoring device as described above.
According to the above scheme, the method for establishing the connection of the monitoring device provided by the embodiment of the invention comprises the following steps: receiving a connection request forwarded by a router through an internal port, wherein the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation; sending a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port; if no other request sent by the client is received within a first preset time length after the response request is sent, canceling the mapping relation between the internal port and the external port at the router, and establishing the mapping relation between the standby port and the external port; and sending the response request to the router through the standby port, so that the router forwards the response request to the client through the external port, and the monitoring device is connected with the client.
It can be seen that, in the scheme, when the client establishes connection with the monitoring device, if the monitoring device does not receive a next request sent by the client after returning a request response to the client through the original port, the monitoring device replaces the original port with the standby port, and automatically modifies the mapping relationship between the router and the monitoring device, so that the response request can be sent to the client through the modified mapping relationship, and the connection between the client and the monitoring device is successfully established, and thus, when the client acquires live and playback data of the monitoring device, a black screen phenomenon caused by the port being disabled by the router is avoided; moreover, the mode of canceling the original port mapping relation and reserving the internal port of the router can ensure that the networking of the NAT is normal, and the problem of abnormal cutoff caused by the change of the internal port can not occur.
The invention also discloses a device, equipment and a system for establishing the connection of the monitoring equipment and a computer readable storage medium, and the technical effects can be realized.
Drawings
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, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram illustrating a conventional monitoring networking in the prior art;
fig. 2 is a schematic structural diagram of a system for establishing a connection between monitoring devices according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a method for establishing a connection between monitoring devices according to an embodiment of the present invention;
fig. 4 is a schematic flowchart of another method for establishing a connection by monitoring equipment according to an embodiment of the present invention;
FIG. 5 is a flowchart of an overall scheme disclosed by an embodiment of the invention;
FIG. 6 is a timing diagram illustrating NAT traversal interaction disclosed in the embodiments of the present invention;
fig. 7 is a schematic structural diagram of an apparatus for establishing connection between monitoring devices according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 invention.
Currently, a router may prohibit some ports from NAT interaction, which may result in data not being transported through the NAT, such as: when the client side obtains the audio and video data of the monitoring device in the NAT, the 554 port of the RTSP is disabled, and the audio and video stream cannot pass through the NAT for transmission, so that the conditions of live and playback of a blank screen occur at the client side. However, an end user in actual operation cannot perceive that the problem is caused by disabling 554 ports by the router, and cannot know that modifying the RTSP ports can avoid the problem, and meanwhile, the RTSP ports are directly modified, so that the RTSP ports do not conform to a standard protocol, problems of consistency and compatibility may exist, and abnormal cutoff of RTSP by the NAT may also be caused.
Therefore, in the present application, a method, an apparatus, a device, a system, and a computer readable storage medium for establishing connection of a monitoring device are disclosed, by using the present solution, a problem that a live function and a playback function are unavailable due to a port such as router disabling 554 can be avoided for the monitoring device in the NAT, and meanwhile, it is ensured that the 554 port of the device in the NAT is not changed, and that networking of the NAT is normal, and an abnormal cutoff problem due to RTSP port change does not occur.
For convenience of understanding, a system architecture applicable to the technical solution of the present application is introduced below, in the present application, the system may include a client, a router, and an electronic device, in this embodiment, the electronic device is described by taking a monitoring device as an example, and refer to fig. 2, which is a schematic diagram of a system structure for establishing a connection for a monitoring device disclosed in the embodiment of the present invention. As can be seen from fig. 1, the system may include a client 11, a router 12, and a monitoring device 13.
Wherein, the client 11 is used to send the connection request to the router 12 through the external port, and the client 11 may include but is not limited to: smart phones, tablet computers, notebook computers, desktop computers and the like or smart wearable devices and the like.
The router 12 is configured to implement data interaction between the client 11 and the monitoring device 13, and forward a connection request sent by the client to the monitoring device 13.
The monitoring device 13 is configured to receive a connection request through the internal port, and send a response request corresponding to the connection request to the router 12 through the internal port, and the router 12 forwards the response request to the client 11 through the external port; if the monitoring device 13 does not receive other requests sent by the client 11 within the first predetermined time after the response request is sent, replacing the internal port with the standby port, and establishing a mapping relationship between the standby port and the external port in the router 13; and then sends the response request to the router 13 through the standby port, so that the router 13 forwards the response request to the client through the external port, thereby establishing the connection between the monitoring device and the client. In addition, the monitoring device in the application can be any video acquisition device such as NVR and IPC.
Referring to fig. 3, a schematic flow chart of a method for establishing a connection by a monitoring device according to an embodiment of the present invention is shown; the method specifically comprises the following steps:
s101, receiving a connection request forwarded by a router through an internal port, wherein the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
it can be understood that the internal port and the external port in the present application are two ports having a mapping relationship, when the client sends a connection request to the monitoring device, the connection request needs to be sent to the external port of the router, and the router forwards the connection request to the monitoring device through the internal port by using the mapping relationship between the internal port and the external port.
Specifically, if the client and the monitoring device perform audio/video code stream transmission through RTSP, the connection request is an OPTIONS request for establishing RTSP connection, which is forwarded by the router and received through the internal port. In this embodiment, the RTSP internal port may be set to 554, and the RTSP external port may be set to 8554, so that the connection request is sent to the router through the 8554 port, and the router sends the connection request to the monitoring device through the 554 port.
S102, sending a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
in this embodiment, after receiving the connection request, the monitoring device sends a response request corresponding to the connection request to the client through the internal port and the external port; if the router does not disable the internal port, the response request is sent to the client through the router, and the client continues to issue other connection requests to the monitoring equipment; if the router disables the internal port, the client will not receive the response request. Specifically, if the connection request is an OPTIONS request for establishing an RTSP connection, since the OPTIONS request is a method for querying the monitoring device to use, the response command returned by the monitoring device to the client includes available methods for the monitoring device, such as: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, and the like.
S103, if other requests sent by the client are not received within the first preset time after the response request is sent, the mapping relation between the internal port and the external port is cancelled in the router, and the mapping relation between the standby port and the external port is established;
it can be understood that, when establishing an RTSP connection, the client first sends an OPTIONS connection request to the monitoring device, and after acquiring the parameters in the response request, the client sends other requests to the monitoring device, for example: a DESCRIBE request (to get session description information), a SETUP request (to remind the server to establish a session and determine the transmission mode), etc. However, if the router disables part of the ports, and the client cannot receive the response request sent by the monitoring device, the client will not send other requests to the monitoring device.
Therefore, in order to ensure that the router does not fail to establish a connection due to port disabling, the monitoring device starts timing after sending a response request to the client, and determines whether other requests sent by the client are received within a first predetermined time period; if other requests are received, it means that the router does not disable the port, and then no subsequent process needs to be executed, and if other requests are not received, it means that the router may not send a response request to the client due to disabling the port, and then the present solution may replace the internal port with a backup port, that is: and canceling the mapping relation between the original internal port and the external port, establishing the mapping relation between the standby port and the external port, and sending a response request to the client through the router again through the reestablished port mapping relation. For example: if the RTSP internal port is 554 and the external port is 8554, the mapping relationship is between 554 and 8554, and when the RTSP is established, the request is sent through the 554 port and the 8554 port; if the 554 port is replaced by the 555 port, the mapping relationship between the 554 port and the 8554 port needs to be cancelled, the mapping relationship between the 555 port and the 8554 port needs to be established, and the request is sent through the 555 port and the 8554 port.
And S104, sending the response request to the router through the standby port so that the router forwards the response request to the client through the external port, thereby establishing the connection between the monitoring equipment and the client.
In the application, after the internal port is replaced by the standby port, the response request is sent to the client through the reestablished mapping relationship between the standby port and the external port again, the establishment of the RTSP connection between the monitoring device and the client is completed, and the audio and video stream is transmitted. It should be noted that, if the internal port is replaced by the standby port, or another request sent by the client cannot be received, this indicates that instruction transmission is not interrupted due to the router disabling the port, and may be caused by another reason, such as a network failure problem, a device failure problem, and the like, and this problem may be reported to an administrator, and the administrator may perform manual repair.
In summary, when the client establishes connection with the monitoring device, if the monitoring device does not receive a next request sent by the client after returning a request response to the client through the original port, the monitoring device replaces the original port with the standby port, and automatically modifies the mapping relationship between the router and the monitoring device, so that the response request can be sent to the client through the modified mapping relationship, and the connection between the client and the monitoring device is successfully established, and thus, when the client acquires live and playback data of the monitoring device, a black screen phenomenon caused by the port being disabled by the router is avoided; moreover, the mode of canceling the original port mapping relation and reserving the internal port of the router can ensure that the networking of the NAT is normal, and the problem of abnormal cutoff caused by the change of the internal port can not occur.
Referring to fig. 4, a schematic flow chart of another method for establishing a connection by monitoring equipment according to an embodiment of the present invention is shown; it should be noted that, the same parts of the present embodiment and the previous embodiment may be referred to each other, and are not described herein again; in this embodiment, the method may specifically include:
s201, receiving a connection request forwarded by a router through an internal port, wherein the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
s202, sending a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
s203, if other requests sent by the client are not received within a first preset time length after the response request is sent, sending a keep-alive command to the client through the router;
s204, judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length; if yes, go to S205; if not, ending the flow;
it is understood that if the monitoring device does not receive other requests sent by the client within the first predetermined time period, it may be caused by a port disabling problem, or a network failure or a device failure problem. Therefore, in this embodiment, in order to avoid that a response request still cannot be sent through the modified port mapping relationship after the port mapping relationship is modified, thereby causing invalid modification of the port mapping relationship, before the mapping relationship is modified, a keep-alive command is sent to the client, so as to detect whether a network or the client fails, thereby eliminating other possible problems.
Specifically, the port for sending the keep-alive command is different from the port for sending the connection request, the port for sending the keep-alive command is an http port, and the port for sending the connection request is an RTSP port, so that the problem of port disabling does not occur. The specific process of sending the keep-alive command by the monitoring equipment and the client comprises the following steps: the monitoring equipment sends a keep-alive command to the client through the router and starts timing; if the network or the device fails, the client will not receive the keep-alive command, and will not send a keep-alive response command to the monitoring device, that is: the monitoring device does not receive the keep-alive response command within a second predetermined time period after sending the keep-alive command, and the monitoring device knows that the reason why the client sends other requests is not received, because the network or the device fails, but the port is disabled. On the contrary, if the network is correct and has not failed, the client may successfully receive the keep-alive command and send a keep-alive response command to the monitoring device through the router, and after the monitoring device receives the keep-alive command, the monitoring device knows that the network between the client and the monitoring device is normal, and if it can be determined that the response request cannot be received by the client due to port disabling, the steps S205-S207 are continuously executed.
S205, sending a mapping relation canceling instruction to the router, wherein the mapping relation canceling instruction is used for canceling the mapping relation between the internal port and the external port;
and S206, if the prompt message that the mapping relation cancellation is successful is received, the mapping relation creating instruction is sent to the router and used for creating the mapping relation between the standby port and the external port.
And S207, if the prompt information that the mapping relation is successfully established and sent by the router is received, sending the response request to the router through the standby port, so that the router forwards the response request to the client through the external port, and connection between the monitoring equipment and the client is established.
In this embodiment, when replacing the internal port with the backup port, the monitoring device needs to interact with the router, first sends a mapping relationship canceling instruction to the router, cancels the mapping relationship between the internal port and the external port, if the cancellation is successful, the router sends a prompt message that the mapping relationship is canceled successfully to the monitoring device, at this time, the monitoring device sends a mapping relationship creating instruction to the router again to create the mapping relationship between the backup port and the external port, if the construction is successful, the router sends a prompt message that the mapping relationship is created successfully to the monitoring device, and only after the mapping relationship is successfully canceled and created, the response request is sent to the router again through the backup port, thereby ensuring the successful modification of the mapping relationship.
The method for establishing a connection with a monitoring device according to this embodiment is described below with a specific application scenario example. In this embodiment, the monitoring device is an NVR, the client and the NVR need to establish an RTSP connection, and a connection request sent by the client to the NVR is an OPTIONS request. The standard port (internal port) of RTSP is 554, the spare port is 555, the external port of RTSP is 8554, the IP address of NVR is 192.168.1.100, and the WAN port address of router is 192.168.0.10.
Referring to fig. 5, an overall scheme flow diagram provided by an embodiment of the present invention; as can be seen from the figure, the scheme is mainly divided into the following steps:
the first step is as follows: the NVR records the external port number mapped by the port, and the client adds the NVR;
wherein, the external port number is the port number of the external port, and the step mainly includes: the monitoring device initiates a UPNP (Universal Plug and Play) and records the mapped port, the client adds the monitoring device, and the monitoring device sends an RTSP address carrying an external port to the client, for example: after the NVR is accessed to the router, UPNP port mapping is started, ports such as HTTP and RTSP are mapped to the outside of the NAT, wherein the 554 port is mapped to 8554, then the NVR is added to the client, the NVR is online, and RTSP url played back live is returned to the client, wherein the RTSP url format is as follows: rtsp://192.168.0.10:8554/media/video1, 192.168.0.10 is the WAN port address of the router, and 8554 is the external port after NVR port mapping.
The second step is that: the client initiates an RTSP live request, the NVR detects that no subsequent process exists after the RTSP OPTIONS signaling is returned, initiates a keep-alive command, and confirms whether the client is online or not.
The third step: the NVR cancels the port mapping of the RTSP port 554 and maps the 555 port to the 8854 port, and the NVR continues to complete RTSP signaling interaction and audio and video streaming transmission through the 555 port.
It should be noted that, the overall flowchart in fig. 5 does not specifically describe the process of initiating the keep-alive command, and referring to fig. 6, a NAT traversal interaction timing diagram provided for the embodiment of the present invention is described through the timing diagram, where the third step and the fourth step are described specifically, and the description specifically includes:
f1: and the client establishes RTSP connection to an RTSP external mapping port of a monitoring device (NVR) and sends an OPTIONS request.
F2: the router forwards the OPTIONS to the NVR.
F3: the NVR responds to the OPTIONS request and returns a response request.
F4: the router disables 554 the port, so no forwarding is done to the return packet in F3, at which time NVR initiates keep-alive through the HTTP port.
F5: the router forwards the keep-alive command to the client.
F6: the client responds to the keep-alive command.
F7: the router forwards the keep-alive command to the NVR.
F8: the NVR unmaps the port mapping of the RTSP 554 port.
F9: the router returns that the cancellation of the port mapping is successful.
F10: the NVR maps the 555 port to the external mapped port of the previous 554 port.
F11: the router returns that the port mapping is successful.
F12: and the NVR continuously returns the response request through the 555 port, and completes subsequent RTSP stream building and audio/video stream transmission at the 555 port.
F13: and the router forwards the message.
In summary, in the present application, a mechanism for automatically modifying port mapping may be established through interaction between the http keep-alive command and the RTSP signaling between the client and the monitoring host, so as to solve the problem that the monitoring device in the NAT is disabled 554 by the router, so as to solve the problem that the monitoring device in the NAT cannot live and playback.
The apparatus for establishing connection of monitoring devices according to the embodiments of the present invention is introduced below, and the apparatus for establishing connection of monitoring devices described below and the method for establishing connection of monitoring devices described above may refer to each other.
Referring to fig. 7, a schematic structural diagram of a device for establishing connection of monitoring equipment according to an embodiment of the present invention is provided; the device comprises:
a receiving module 21, configured to receive a connection request forwarded by a router through an internal port, where the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relationship;
a first sending module 22, configured to send a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
a port replacement module 23, configured to cancel, at the router, a mapping relationship between the internal port and the external port and establish a mapping relationship between the standby port and the external port when the response request is sent within a first predetermined time period after the response request is sent and other requests sent by the client are not received;
a second sending module 24, configured to send the response request to the router through the standby port, so that the router forwards the response request to the client through the external port, thereby establishing a connection between the monitoring device and the client.
Wherein the receiving module is specifically configured to: and receiving an OPTIONS request for establishing RTSP connection forwarded by the router through the internal port.
Wherein the port replacement module comprises:
a first instruction sending module, configured to send a mapping relationship canceling instruction to the router, where the mapping relationship canceling instruction is used to cancel a mapping relationship between the internal port and the external port;
and a second instruction sending module, configured to send a mapping relationship creating instruction to the router when receiving a prompt that the mapping relationship cancellation is successful, where the mapping relationship creating instruction is used to create a mapping relationship between the standby port and the external port.
The second sending module is specifically configured to: and when receiving prompt information that the mapping relation is successfully established and sent by the router, sending the response request to the router through the standby port.
Wherein, this scheme still includes:
a third sending module, configured to send a keep-alive command to the client through the router;
the judging module is used for judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length;
the port replacement module is configured to cancel, at the router, the mapping relationship between the internal port and the external port and establish the mapping relationship between the standby port and the external port when a keep-alive response command forwarded by the client through the router is received within a second predetermined time period.
Referring to fig. 8, an electronic device according to an embodiment of the present invention includes:
a memory 31 for storing a computer program;
a processor 32 adapted to carry out the steps of the method of establishing a connection of a monitoring device as described in any of the method embodiments above when said computer program is executed.
In this embodiment, the device may be a NVR or IPC device.
The device may include a memory 31, a processor 32 and a bus 33.
The memory 31 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 31 may in some embodiments be an internal storage unit of the device, for example a hard disk of the device. The memory 31 may also be an external storage device of the device in other embodiments, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) Card, Flash memory Card (Flash Card), etc. provided on the device. Further, the memory 31 may also include both an internal storage unit of the device and an external storage device. The memory 31 may be used to store not only application software installed in the device but also various data.
Processor 32, which in some embodiments may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip, executes program code stored in memory 31 or processes data.
The bus 33 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 in FIG. 8, but this is not intended to represent only one bus or type of bus.
Further, the device may further include a network interface 34, and the network interface 34 may optionally include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are generally used to establish a communication connection between the device and other electronic devices.
Fig. 8 shows only a device with components 31-34, and it will be understood by those skilled in the art that the structure shown in fig. 8 does not constitute a limitation of the device, and may include fewer or more components than shown, or some components may be combined, or a different arrangement of components.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for establishing a connection by monitoring equipment according to any of the above-mentioned method embodiments are implemented.
Wherein the storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use 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 (10)

1. A method for a monitoring device to establish a connection, comprising:
receiving a connection request forwarded by a router through an internal port, wherein the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
sending a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
if other requests sent by the client are not received within a first preset time length after the response request is sent, canceling the mapping relation between the internal port and the external port at the router, and establishing the mapping relation between a standby port and the external port;
and sending the response request to the router through the standby port, so that the router forwards the response request to the client through the external port, and the monitoring device is connected with the client.
2. The method of claim 1, wherein receiving the connection request forwarded by the router through the internal port comprises:
and receiving an OPTIONS request for establishing RTSP connection forwarded by the router through the internal port.
3. The method of claim 1, wherein canceling the mapping between the internal port and the external port and establishing the mapping between the standby port and the external port at the router comprises:
sending a mapping relation canceling instruction to the router, wherein the mapping relation canceling instruction is used for canceling the mapping relation between the internal port and the external port;
and if receiving prompt information that the mapping relation cancellation sent by the router is successful, sending a mapping relation establishing instruction to the router, wherein the mapping relation establishing instruction is used for establishing the mapping relation between the standby port and the external port.
4. The method of claim 3, wherein sending the response request to the router through the backup port comprises:
and if receiving prompt information that the mapping relation is successfully established and sent by the router, sending the response request to the router through the standby port.
5. The method according to any one of claims 1 to 4, wherein if no other request sent by the client is received within a first predetermined time period after sending the response request, the method further comprises:
sending a keep-alive command to the client through the router;
judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length;
if yes, the step of canceling the mapping relation between the internal port and the external port and establishing the mapping relation between the standby port and the external port in the router is executed.
6. An apparatus for monitoring device connection establishment, comprising:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a connection request forwarded by a router through an internal port, the connection request is sent to the router through an external port by a client, and the internal port and the external port have a mapping relation;
a first sending module, configured to send a response request corresponding to the connection request to the router through the internal port, so that the router forwards the response request to the client through the external port;
a port replacement module, configured to cancel, at the router, a mapping relationship between the internal port and the external port and establish a mapping relationship between a standby port and the external port when the response request is sent within a first predetermined time period after the response request is sent and other requests sent by the client are not received;
and the second sending module is used for sending the response request to the router through the standby port so that the router forwards the response request to the client through the external port, and thus the connection between the monitoring device and the client is established.
7. The apparatus of claim 6, further comprising:
a third sending module, configured to send a keep-alive command to the client through the router;
the judging module is used for judging whether a keep-alive response command forwarded by the client through the router is received within a second preset time length;
the port replacement module is configured to cancel, at the router, the mapping relationship between the internal port and the external port and establish the mapping relationship between the standby port and the external port when a keep-alive response command forwarded by the client through the router is received within a second predetermined time period.
8. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the method of establishing a connection by a monitoring device according to any of claims 1 to 5 when executing the computer program.
9. A connection establishment system, comprising: client, router, and electronic device according to claim 8.
10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the method for a monitoring device to establish a connection according to one of claims 1 to 5.
CN202010186648.8A 2020-03-17 2020-03-17 Method, device, equipment, system and storage medium for establishing connection of monitoring equipment Active CN113411367B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010186648.8A CN113411367B (en) 2020-03-17 2020-03-17 Method, device, equipment, system and storage medium for establishing connection of monitoring equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010186648.8A CN113411367B (en) 2020-03-17 2020-03-17 Method, device, equipment, system and storage medium for establishing connection of monitoring equipment

Publications (2)

Publication Number Publication Date
CN113411367A CN113411367A (en) 2021-09-17
CN113411367B true CN113411367B (en) 2022-07-19

Family

ID=77677148

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010186648.8A Active CN113411367B (en) 2020-03-17 2020-03-17 Method, device, equipment, system and storage medium for establishing connection of monitoring equipment

Country Status (1)

Country Link
CN (1) CN113411367B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104363143A (en) * 2014-11-27 2015-02-18 上海斐讯数据通信技术有限公司 Port mapping test method of wireless router
CN108540590A (en) * 2018-03-28 2018-09-14 深圳市网心科技有限公司 UPnP network port mapping method, electronic equipment, network system and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7676579B2 (en) * 2002-05-13 2010-03-09 Sony Computer Entertainment America Inc. Peer to peer network communication
US10505757B2 (en) * 2014-12-12 2019-12-10 Nxp Usa, Inc. Network interface module and a method of changing network configuration parameters within a network device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104363143A (en) * 2014-11-27 2015-02-18 上海斐讯数据通信技术有限公司 Port mapping test method of wireless router
CN108540590A (en) * 2018-03-28 2018-09-14 深圳市网心科技有限公司 UPnP network port mapping method, electronic equipment, network system and storage medium

Also Published As

Publication number Publication date
CN113411367A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
CN106789153B (en) Multi-channel self-adaptive log recording and outputting method and system for terminal equipment of Internet of things system
US20150304364A1 (en) Method, System, and Terminal for Web Real-Time Communication
US10417061B2 (en) Operating method of routing device, routing device, and terminal device
US8700820B2 (en) Method for accessing USB device attached to home gateway, home gateway and terminal
CN108337333B (en) IP address management method, management device, network video recorder and storage medium
WO2009097776A1 (en) System, device and method for achieving service upgrade
US9370032B2 (en) Service processing method and apparatus based on android system
CN110650193B (en) Node management method, cluster management device and storage medium
CN112398689B (en) Network recovery method and device, storage medium and electronic equipment
JP5255035B2 (en) Failover system, storage processing apparatus, and failover control method
CN111246152A (en) Video conference automatic recovery method and device, storage medium and electronic device
WO2021042612A1 (en) Wireless screen projection method and apparatus, device and storage medium
TW202021314A (en) Network service system and network service method
CN113411367B (en) Method, device, equipment, system and storage medium for establishing connection of monitoring equipment
CN103051484B (en) Session service processing method, system and Session Border Controll
CN108810611A (en) The control system and method for Multimedia Fusion terminal start-up course
CA2936055A1 (en) Access control device, communication system, program, and method for controlling access
CN111416851A (en) Method for session synchronization among multiple load balancers and load balancer
CN110808996A (en) Network authentication method and device, electronic equipment and storage medium
CN103856572A (en) Terminal device IP address contract extension method and household gateway
CN113596197B (en) Address switching method and device, electronic equipment and storage medium
EP3297254B1 (en) Domain name system (dns) resolution processing method and device
CN105792385B (en) Communication method and device based on wireless local area network
CN110830305A (en) Method and device for accessing wireless device to WIFI network, electronic device and storage medium
CN105634810B (en) method and system for accessing universal plug and play device and access device

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
GR01 Patent grant
GR01 Patent grant