Remote calling method, device and system of Internet of Things terminal

By setting up the encapsulation and forwarding mechanism of the HTTP interface and MQTT protocol in the IoT terminal system, the problem of synchronous communication between IoT terminals is solved, real-time communication and flexible remote call functions are realized, and maintenance costs are reduced.

CN119814749APending Publication Date: 2025-04-11BEIJING INHAND NETWORKS TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311314224.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-11
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In the prior art, synchronous communication between IoT terminals is difficult to achieve, especially when using the MQTT protocol, Pub/Sub mode is not suitable for synchronous communication, resulting in inefficient efficiency when remotely calling control devices, and predefined command names and parameters are required, which increases maintenance costs.

Method used

Set up an HTTP interface on the server and provide local HTTP request proxy service on the device side. The HTTP request is encapsulated and transmitted to the device side through the MQTT protocol. After the device side parses and processes it, the response is encapsulated as an MQTT message and returned to the server side, and the result is finally sent to the request side.

Benefits of technology

Real-time communication between the server and the device terminal is realized, avoiding the limitation of predefined commands, reducing maintenance costs, and supporting proxy forwarding of local HTTP requests for the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814749A_ABST
    Figure CN119814749A_ABST
Patent Text Reader

Abstract

The invention discloses a remote calling method for an internet of things terminal, which comprises the following steps of: setting an HTTP (Hyper Text Transport Protocol) interface at a server side, and providing local HTTP request proxy service at an equipment side; the request end can send an HTTP request of the remote control equipment end to the server end; after the server side receives the HTTP request, the request is packaged into an MQTT message, and the MQTT message is sent to the corresponding equipment side; after receiving the MQTT message, the device side analyzes the message to obtain an HTTP request; the device end sends the analyzed HTTP request to a local HTTP server, and waits for obtaining an HTTP response; the device side encapsulates the HTTP response into an MQTT message and sends the MQTT message to the server side; and after receiving the MQTT message, the server analyzes the MQTT message to obtain an HTTP response, and sends the HTTP response to the request end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a remote calling method, device and system for an Internet of Things terminal. Background Art

[0002] With the rapid development of the industrial Internet of Things industry, a major notable feature of various industrial devices or terminals contained in the existing industrial automation system is "fragmentation". That is, in the current industrial Internet of Things, due to the wide variety of existing devices or terminals, the data transmission protocols used are also different. The MQTT protocol is a message queue transmission protocol that adopts a subscription and publishing mechanism. Subscribers only receive the data they have subscribed to, and do not receive the subscribed data. This ensures the exchange of necessary data and avoids the storage and processing of invalid data. Therefore, it is widely used in the industrial Internet of Things.

[0003] When implementing IoT applications, it is often necessary to synchronously control the device end on the server end and view the control results in real time. For example, (remotely restart the device, remotely modify the controller parameters, etc.). In the IoT system, the device often uses the MQTT protocol to establish a management channel with the server end, and the server end and the terminal use the MQTT protocol for two-way communication. However, the MQTT protocol is a Pub / Sub mode communication protocol, which is not suitable for synchronous communication.

[0004] In order to solve the problem of synchronous communication, the existing technology adopts the solution of RRPC technology. The server developer and the device end pre-agree on all supported commands and define the parameters of these commands, etc., and then use the MQTT protocol to communicate and transmit the pre-defined RRPC request. After receiving the request, the device parses the name of the remote method to be executed, and then executes it locally. Finally, the execution result is sent to the server through the RRPC response message. The server encapsulates the RRPC request into an HTTP request, which can be called by the SPA (Web end) of the server to achieve the purpose of remote control of the device. The disadvantage of the above method is that in the case of using RRPC requests, all remote access calls that need to be supported need to pre-define the command name and command parameters. When new commands need to be supported, new command names and command parameters need to be defined to achieve it, and both the server and the device need to adapt the newly added methods according to the agreement. There is a certain amount of maintenance work. Some network devices, in addition to supporting remote management, also provide a local web management interface, allowing users to open it locally and control the device. The control functions provided in the local web management interface often need to be provided remotely. This results in operations such as restarting, which require the device side to provide a connection to the web side based on http, and at the same time, to provide a connection to the server side RRPC mode based on http. The same function needs to be executed twice. Moreover, when the server and the device are not in the same network, due to the isolation of firewalls and NAT, the server cannot directly call the http method on the device side.

[0005] Therefore, there is a need in the prior art for a method that can effectively implement remote call control of an Internet of Things terminal and achieve real-time communication between a server and a device terminal. Summary of the invention

[0006] The present invention provides a remote calling method for an Internet of Things terminal, which solves the problem of effective real-time communication between a server end and a device terminal in the current Internet of Things.

[0007] To achieve the above technical objectives, the present invention provides a remote calling method for an Internet of Things terminal, the method comprising:

[0008] Step S101, set up an HTTP interface on the server side and provide a local HTTP request proxy service on the device side. The request side can send an HTTP request to the server side to remotely control the device side;

[0009] Step S102, when the server receives the HTTP request, it encapsulates the request into an MQTT message and sends the MQTT message to the corresponding device;

[0010] Step S103, after receiving the MQTT message, the device parses the message to obtain an HTTP request;

[0011] Step S104, the device sends the parsed HTTP request to the local HTTP server and waits for an HTTP response;

[0012] Step S105, the device encapsulates the HTTP response into an MQTT message and sends it to the server;

[0013] Step S106, after receiving the MQTT message, the server parses it to obtain an HTTP response, and sends the HTTP response to the requester.

[0014] In one embodiment, the MQTT message data encapsulated by the HTTP request includes an identification ID of the HTTP request, a request method of the HTTP request, and a request path of the HTTP request.

[0015] In one embodiment, the MQTT message data encapsulated by the HTTP response includes an identification ID of the HTTP response and a local status code of the HTTP response.

[0016] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0018] Figure 1 It is a flow chart of the remote calling method of the Internet of Things terminal of the present invention. DETAILED DESCRIPTION

[0019] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings.

[0020] The remote calling method of the Internet of Things terminal of this embodiment includes:

[0021] Step S101, set up HTTP interface on the server side, and provide local HTTP request proxy service on the device side. The request side can send HTTP request for remote control of the device side to the server side.

[0022] Step S102, when the server receives the HTTP request, it encapsulates the request into an MQTT message and sends the MQTT message to the corresponding device.

[0023] Step S103, after receiving the MQTT message, the device parses the message to obtain an HTTP request.

[0024] In step S104, the device sends the parsed HTTP request to the local HTTP server and waits for an HTTP response.

[0025] In step S105, the device encapsulates the HTTP response into an MQTT message and sends it to the server.

[0026] Step S106, after receiving the MQTT message, the server parses it to obtain an HTTP response, and sends the HTTP response to the requester.

[0027] The specific implementation process of this embodiment is as follows:

[0028] The cloud defines an http request in the format of / device / {deviceId} / proxy / **, where deviceId indicates the device ID of the desired remote call request. ** indicates the local http request path of the device you actually want to call. For example, sending a GET request to / device / 123 / proxy / get-system-info indicates a local http request to remotely call device 123: GET / get-system-info.

[0029] After receiving the http request, the cloud obtains the entire content of the http request and encapsulates the MQTT message Payload to be forwarded. The HTTP request encapsulation format is:

[0030]

[0031] Definition of the encapsulated request message Payload:

[0032] requestId: Request ID, used to uniquely identify requests and responses.

[0033] Method: request method, corresponding to HTTP request method, such as: GET, POST, PUT, DELETE, etc.

[0034] Url: The requested path. It only contains the request path and URL parameters.

[0035] Headers: HTTP request headers.

[0036] Body: HTTP request body.

[0037] The entire payload is in JSON format.

[0038] JSON, or other data formats such as cbor, msgpack, etc.

[0039] When using JSON, the body needs to be encoded in base64 or other formats to be used in traditional binary formats for HTTP request bodies. When using other compatible binary formats, the body can be the original HTTP request body directly.

[0040] The encapsulated MQTT message is forwarded to topic:device / {deviceId} / proxy / request, where deviceId is the device ID.

[0041] The device needs to establish an MQTT connection with the cloud and subscribe to the topic: device / {deviceId} / proxy / request. After receiving the proxy request message sent by the cloud, the device parses the actual content of the http request. The device assembles the local request URL: https: / / localhost / get-system-info according to the URL in the httprqeuest, where https: / / localhost is the real address of the local http service, which the device can dynamically identify according to its own situation.

[0042] The device uses the http client to construct an http request, waits for the local http server to respond, and encapsulates the http response mqtt payload, and sends the encapsulated MQTT message to the topic: device / {deviceId} / proxy / response. If the local request fails or times out, it directly replies to the server with status code 502, and the body of the reply is "Bad Gateway" or other specific error information. The HTTP response encapsulation format is:

[0043]

[0044] Specific fields of response payload:

[0045] requestId: the same as requestId in the request.

[0046] Status: The status code of the local http response.

[0047] Headers: Headers of local http response.

[0048] Body: The content of the local http response.

[0049] The cloud monitors the topic device / + / proxy / response and receives the response messages sent back by all devices. After receiving the response message, it finds the waiting original http request according to the request id and returns the status code, response header, and response body in the proxy http response to the client of the original http request accordingly.

[0050] The present invention may be a system, method and / or computer program product at any possible level of integrated technical detail. The computer program product may include a computer-readable storage medium (or multiple media) having computer-readable program instructions thereon for causing a processor to perform various aspects of the present invention.

[0051] A computer readable storage medium may be a tangible device that can retain and store instructions used by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of computer readable storage media includes the following: a portable computer floppy disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device such as a punch card or a raised structure in a groove on which instructions are recorded, and any suitable combination of the above. A computer readable storage medium, as used herein, should not be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted by a wire.

[0052] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a corresponding computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, optical transmission fibers, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in a computer-readable storage medium within the corresponding computing / processing device.

[0053] The computer-readable program instructions for performing the operation of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, configuration data for integrated circuits, or source code or object code written in any combination of one or more programming languages ​​and process programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer by any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., by using the Internet of an Internet service provider). In certain embodiments, the electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute the computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit, thereby performing aspects of the present invention.

[0054] Various aspects of the present invention are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It is understood that each block of the flowchart illustration and / or block diagram, and the combination of blocks in the flowchart illustration and / or block diagram, can be implemented by computer-readable program instructions.

[0055] These computer-readable program instructions may be provided to a processor of a computer or other programmable data processing device to produce a machine so that the instructions executed by the processor of the computer or other programmable data processing device create instructions for implementing the flowcharts and / or block diagrams. Figure 1 These computer-readable program instructions may also be stored in a computer-readable storage medium capable of booting a computer, a programmable data processing device and / or other device that operates in a specific manner, so that the computer-readable storage medium having the instructions stored therein includes a manufactured product that includes instructions that implement aspects of the functions / actions specified in the flowchart and / or block diagram blocks.

[0056] Computer readable program instructions may also be loaded into a computer, other programmable data processing device, or other device to cause a series of operating steps to be performed on the computer, other programmable devices or other devices for producing a computer-implemented process, so that the instructions executed on the computer, other programmable device or other device implement the functions / actions specified in the flowchart and / or block diagram blocks.

[0057] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, segment or portion of an instruction, which includes one or more executable instructions for implementing a specified logical function. In some optional implementations, the functions indicated in the block may occur outside the order indicated in the figure. For example, in fact, two blocks shown in succession can be completed as a step, and depending on the functions involved, they can be executed concurrently, substantially concurrently, in a partially or fully time-overlapping manner, or sometimes these blocks can be executed in reverse order. It will also be noted that each block of the block diagram and / or flowchart illustration, as well as the combination of blocks in the block diagram and / or flowchart illustration, can be implemented by a dedicated hardware-based system that performs a specified function or action or performs a combination of dedicated hardware and computer instructions.

[0058] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses (devices) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0059] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0060] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0061] The above description is only a specific implementation case of the present invention, and the protection scope of the present invention is not limited thereto. Any modification or replacement of the present invention by any technician familiar with the present technology within the technical specifications described in the present invention should be within the protection scope of the present invention.

Claims

1. A remote calling method for an Internet of Things terminal, characterized in that: The method comprises: Step S101, setting up an HTTP interface on the server side and providing a local HTTP request proxy service on the device side, so that the request side can send an HTTP request to the server side for remotely controlling the device side; Step S102, when the server receives the HTTP request, it encapsulates the request into an MQTT message and sends the MQTT message to the corresponding device; Step S103, after receiving the MQTT message, the device parses the message to obtain an HTTP request; Step S104, the device sends the parsed HTTP request to the local HTTP server and waits for an HTTP response; Step S105, the device encapsulates the HTTP response into an MQTT message and sends it to the server; Step S106, after receiving the MQTT message, the server parses it to obtain an HTTP response, and sends the HTTP response to the requester.

2. The remote calling method according to claim 1, characterized in that: The MQTT message data encapsulated by the HTTP request includes the identification ID of the HTTP request, the request method of the HTTP request and the request path of the HTTP request.

3. The remote calling method according to claim 1, characterized in that: The MQTT message data encapsulated by the HTTP response includes the identification ID of the HTTP response and the local status code of the HTTP response.

4. A computing device comprising: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the data transmission method according to any one of claims 1 to 3 are implemented.

5. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the data transmission method according to any one of claims 1 to 3.

Citation Information

Cited By

  • Method, device and system for bidirectional communication between cloud and terminal equipment

    CN122204850A