CN114363312B - Method for realizing communication between Internet and local area network based on Http protocol - Google Patents

Method for realizing communication between Internet and local area network based on Http protocol Download PDF

Info

Publication number
CN114363312B
CN114363312B CN202210013782.7A CN202210013782A CN114363312B CN 114363312 B CN114363312 B CN 114363312B CN 202210013782 A CN202210013782 A CN 202210013782A CN 114363312 B CN114363312 B CN 114363312B
Authority
CN
China
Prior art keywords
request
response
binary data
data stream
instance
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
CN202210013782.7A
Other languages
Chinese (zh)
Other versions
CN114363312A (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.)
Sichuan Kingscheme Information Technology Co ltd
Original Assignee
Sichuan Kingscheme 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 Sichuan Kingscheme Information Technology Co ltd filed Critical Sichuan Kingscheme Information Technology Co ltd
Priority to CN202210013782.7A priority Critical patent/CN114363312B/en
Publication of CN114363312A publication Critical patent/CN114363312A/en
Application granted granted Critical
Publication of CN114363312B publication Critical patent/CN114363312B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method for realizing communication between the Internet and a local area network based on an Http protocol, which relates to the field of communication between the Internet and the local area network and comprises the following steps: s1, a front-end server receives an HTTP request, encodes corresponding message data into binary data streams and stores the binary data streams in a database; s2, after reading the binary data stream in the database, the post-positioned server establishes connection with the target server, sends the binary data stream to the target server, and waits for the target server to return response data; s3, encoding the response data into a binary data stream and storing the binary data stream in a database; s4, after reading the binary data stream in the database, the front-end server sends the binary data stream to the client; the requested message data is converted into SQL and stored in a database in the local area network, the front-end server and the rear-end server work cooperatively, message data exchange is realized by using the database, and Http communication between the Internet and the local area network is opened.

Description

Method for realizing communication between Internet and local area network based on Http protocol
Technical Field
The invention relates to the field of communication between the Internet and a local area network, in particular to a method for realizing communication between the Internet and the local area network based on an Http protocol.
Background
Some enterprises or institutions are concerned with national secrets; or, in order to protect the business secret, the company constructs a local area network inside the organization and performs a certain degree of isolation from the internet, so as to avoid the attack from the internet and ensure the security of the data assets of the company.
With the further development of the internet and the need of data interaction between the mechanism and the internet, a security isolation hardware device which utilizes a JDBC interface and carries out security examination on SQL sentences passing through the JDBC interface is created, the device ensures the data security of the mechanism to a certain extent, and simultaneously allows a server of the mechanism running on the internet or limited internet to be connected with a database located in an internal network of the mechanism through the security isolation device, thereby realizing the intercommunication between the internal structured data of an enterprise or mechanism and the internet.
Although the security isolation hardware device meets the requirement of limited data intercommunication between enterprises with security management requirements and the internet to a certain extent, the following problems exist in the data interaction mode:
1. data interaction is difficult, unstructured data cannot be interacted, and data such as photos and files at the internet end cannot enter a mechanism local area network directly;
2. the information security risk is increased, and a server providing service for the Internet side needs to be deployed in a machine room of the Internet side, so that the attacked risk and the security management difficulty of the server are increased objectively;
3. the network structure is complex, deployment implementation and operation and maintenance are difficult, for an information system which needs to provide services for an internal local area network and the internet at the same time, the same server software systems need to be deployed at the two ends of the local area network and the internet at the same time, so that the operation and maintenance management difficulty of the information system is increased, and meanwhile, unstructured data generated at the two ends cannot be intercommunicated, so that the reduction of user experience and the loss of data integrity are caused.
Disclosure of Invention
The invention aims to solve the technical problem that data interaction between the Internet and a local area network is difficult, and aims to provide a method for realizing communication between the Internet and the local area network based on an Http protocol, so that the problem that data interaction between the Internet and the local area network is difficult is solved.
The invention is realized by the following technical scheme:
a method for realizing communication between Internet and local area network based on Http protocol includes following steps:
s1, receiving an HTTP request at a front-end server, coding corresponding message data into binary data streams, and storing the binary data streams in a request table of a database through a JDBC interface;
s2, after the post-positioned server reads the binary data stream in the database request table, establishing connection with a target server, sending the binary data stream to the target server, and waiting for the target server to return response data;
s3, coding the response data into a binary data stream by the rear server, and storing the binary data stream into a response table of a database through a JDBC interface;
and S4, after the front-end server reads the binary data stream in the database response table, sending the binary data stream to the client.
The front server is deployed at an internet end, the back server is deployed at a local area network end, the database is used as a data exchange middleware of the front server and the back server, message data and response data are stored in the database in a binary data stream mode, not only can structured data be stored, but also unstructured data such as texts, images, sounds, videos, hypermedia and the like can be stored, a safe and controllable Http service interface is provided through a JDBC interface, so that Http requests in the internet can efficiently access the servers in the local area network through a safety isolation hardware device, an unstructured data interaction channel between the local area network and the internet is opened, and the problem of difficulty in data interaction between the internet and the local area network is solved.
Only one set of service system is deployed in the local area network, and the service system can be simultaneously provided for the Internet and the local area network users, so that the problems of information security risk and operation and maintenance management caused by the deployment of the server at the Internet end are solved.
Further, in the front-end server, after receiving the Http request, encoding the corresponding message data into a binary data stream, including the following steps:
a1, decoding corresponding message data to obtain a request message;
a2, allocating a request ID, and carrying out security check on the URI and Token in the request message;
and A3, coding the request message to obtain a request binary data stream.
The binary data stream can store structured data and unstructured data, and message data corresponding to an Http request sent out from the internet is stored in a database in the form of the binary data stream, so that interaction between the internet and the unstructured data in the local area network can be realized.
Further, the method for storing the binary data stream in the request table of the database in the front-end server includes the following steps:
b1, creating a request Chunk instance, which is used for storing a request ID, a message index and a request binary data stream;
b2, if a request Chunk instance waiting for sending exists, creating a request Payload instance for storing the request Chunk instance;
and B3, encoding the request Payload example to obtain a request Payload binary data stream, and storing the request Payload binary data stream in a request table of the database.
And storing the message data sent by the client through a request Chunk instance, and forwarding the message data to the server, wherein the message data sent by the client is an encoded HTTP protocol data stream. The decoding of the HTTP protocol data stream is to check whether the message data is compliant, and the re-encoding of the message data is to restore the message data to the HTTP protocol data stream. And the inspection step of the message data is added, so that the transmitted message data is more reliable.
The request binary data stream is decomposed into a series of request Chunk instances, and the request Chunk instances are stored in a database request table, so that the front-end server does not need to wait for receiving and then transmitting all the request binary data streams, the back-end server can also receive the request binary data streams more quickly and send the request binary data streams to the target server, the whole request speed is increased, and the request delay is reduced; meanwhile, the residence time of the request binary data stream in the memory of the front-end server or the back-end server is reduced, and the memory pressure of the front-end server or the back-end server is reduced.
And creating a request Payload instance for aggregating the request Chunk instances, and aggregating different request data together, so that the execution times of the JDBC interface are reduced, the database pressure is further reduced, and the transmission efficiency of the JDBC interface is improved.
Further, after reading the binary data stream in the database request table in the post-server, establishing a connection with the target server, and sending the binary data stream to the target server, the method includes the following steps:
decoding the read request Payload binary data stream to obtain a request Payload instance, reading the request Chunk instance, creating a corresponding Http request processing module instance according to the request ID in the request Chunk instance, sequencing the request Chunk instance according to the message index in the request Chunk instance in the Http request processing module instance, and sending the request binary data stream to a target server in sequence.
The method comprises the steps that a post-positioned server in a local area network inquires that a request Payload binary data stream exists in a request table, the request Payload binary data stream is decoded to obtain a request Payload example, one or more request Chunk examples may exist in the request Payload example, the request Chunk example in the request Payload example has one unique request ID, one or more corresponding Http request processing module examples are created according to the request ID, the request Chunk example is sent to the corresponding Http request processing module example according to the request ID in the request Chunk example, and in the Http request processing module example, the request Chunk examples are sequenced according to a message index in the request Chunk example, so that errors of Http coding formats and errors of Http requests caused by disordered sequences sent by the request Chunk examples are avoided.
Further, in the above post-server, encoding the response data into a binary data stream, and storing the binary data stream in a response table of the database through the JDBC interface, includes the following steps:
c1, after receiving the request binary data stream, the target server returns response data, and the post-positioned server decodes the response data to obtain a response message;
c2, coding the response message to obtain a response binary data stream;
c3, creating a response Chunk instance for storing the request ID, the message index and the response binary data stream;
c4, if a response Chunk instance waiting for sending exists, creating a response Payload instance for storing the response Chunk instance;
and C5, encoding the response Payload example to obtain a response Payload binary data stream, and storing the response Payload binary data stream in a response table of the database.
The response data is stored in a database in a binary data stream mode, and the local area network realizes the interaction of the unstructured data of the Internet and the local area network on the response data generated by the Http request sent out in the Internet.
The response binary data stream is decomposed into a series of response Chunk instances, and one or more response Chunk instances are stored in the database response table, so that the back-end server does not need to wait for receiving and then transmitting all the response binary data streams, the front-end server can also receive the response binary data streams more quickly and send the response binary data streams to the client, the whole response speed is accelerated, and the response delay is reduced; meanwhile, the residence time of the response binary data stream in the memory of the front-end server or the back-end server is reduced, and the memory pressure of the front-end server or the back-end server is reduced.
And creating a response Payload instance for aggregating response Chunk instances and aggregating different response data together, so that the execution times of the JDBC interface are reduced, the database pressure is further reduced, and the transmission efficiency of the JDBC interface is improved.
Further, in the front-end server, after the binary data stream in the database response table is read, the binary data stream is sent to the client, and the method includes the following steps:
decoding the read response Payload binary data stream to obtain a response Payload example; and reading the response Chunk instance, searching the corresponding Http request processing module instance according to the request ID in the response Chunk instance, sequencing the response Chunk instance according to the message index in the response Chunk instance in the Http request processing module instance, and sending response binary data streams to the client in sequence.
The response Pattern instance stores one or more response Chunk instances, wherein each response Chunk instance is used for storing a response binary data stream obtained by response message coding, the response binary data stream is obtained by response message coding, a corresponding Http request processing module instance is searched according to a request ID in the response Chunk instance, and the response Chunk instance is sent to the corresponding Http request processing module instance.
Further, in the front-end server, if the request has an error, the request message or the response message is encoded into binary data and sent to the client.
The above request error conditions include JDBC interface connection error, write failure, write timeout, query return timeout, etc.
Further, the requesting Payload binary data stream to be stored in the request table of the database includes the following steps:
d1, calculating whether the space occupied by the coded request Payload instance is less than 64KB;
d11, if the space occupied by the coded request Payload instance is less than 64KB, checking whether a next request Chunk instance exists;
if the next request Chunk instance does not exist, encoding the request Payload instance to obtain a request Payload binary data stream, and calling the JDBC interface to store the request Payload binary data stream in a request table of the database;
if the next request Chunk instance exists, checking whether the remaining space of the request Payload instance can store the next request Chunk instance;
d111, if yes, saving the next request Chunk instance into the request Payload instance, and repeating D1;
d112, if the request Payload instance cannot be encoded, obtaining a request Payload binary data stream, and calling a JDBC interface to store the request Payload binary data stream in a request table of a database;
and D12, if the space occupied by the request Payload instance after encoding is larger than or equal to 64KB, encoding the request Payload instance to obtain a request Payload binary data stream, and calling a JDBC interface to store the request Payload binary data stream in a request table of a database.
The request Payload instance aggregates the request Chunk instances into data of about 64KB, and then transmits the request Chunk instances to the database through the JDBC interface, most of the request data do not exceed 1KB, the execution times of the JDBC interface after the request Chunk instances are aggregated are reduced to 1/64 of the execution times before aggregation, the pressure of the database is reduced, and the transmission efficiency of the JDBC interface is improved.
Further, the step of storing the response Payload binary data stream in a response table of the database includes the following steps:
e1, calculating whether the space occupied by the coded response Payload example is less than 64KB;
e11, if the space occupied by the coded response Payload instance is less than 64KB, checking whether a next response Chunk instance exists;
if the next response Chunk instance does not exist, encoding the response Payload instance to obtain a response Payload binary data stream, and calling the JDBC interface to store the response Payload binary data stream in a response table of the database;
if the next response Chunk instance exists, checking whether the remaining space of the response Payload instance can store the next response Chunk instance;
e111, if yes, storing the next response Chunk instance into the response Payload instance, and repeating E1;
e112, if the response Payload instance cannot be obtained, encoding the response Payload instance to obtain a response Payload binary data stream, and calling a JDBC interface to store the response Payload binary data stream in a response table of the database;
and E12, if the space occupied by the response Payload instance after encoding is larger than or equal to 64KB, encoding the response Payload instance to obtain a response Payload binary data stream, and calling the JDBC interface to store the response Payload binary data stream in a response table of the database.
The response Payload instance aggregates the response Chunk instances into data of about 64KB, then transmits the response Chunk instances to the database through the JDBC interface, most of the response data are calculated to be not more than 1KB, the execution times of the JDBC interface are reduced to 1/64 of the execution times before aggregation after the response Chunk instances are aggregated, the pressure of the database is reduced, and the transmission efficiency of the JDBC interface is improved.
Furthermore, after the binary data stream in the database request table or the response table is read, the binary data stream in the database request table or the response table is deleted, the read binary data stream occupies the space of the database, and the data is deleted after the data is read, so that the space of the database is released, and the response efficiency is improved.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the database is used as a data exchange middleware of the front server and the back server, message data and response data are stored in the database in a binary data stream mode, structured data can be stored, unstructured data such as texts, images, sounds, videos, hypermedia and the like can also be stored, a safe and controllable Http service interface is provided through a JDBC interface, so that Http requests in the internet can efficiently access servers in a local area network through a safety isolation hardware device, an unstructured data interaction channel between the local area network and the internet is opened, and the problem that data interaction between the internet and the local area network is difficult is solved.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and that for those skilled in the art, other related drawings can be obtained from these drawings without inventive effort. In the drawings:
FIG. 1 is a main flow chart provided in example 1;
fig. 2 is a flowchart of the front end server processing Http request provided in embodiment 1;
fig. 3 is a flowchart of the Http request processing by the post server provided in embodiment 1;
fig. 4 is a flowchart of the post-server processing Http response provided in embodiment 1;
fig. 5 is a flowchart of the front-end server processing Http response provided in embodiment 1;
FIG. 6 is a block diagram of a system provided in embodiment 2;
FIG. 7 is a block diagram of the structure of an example Payload and an example Chunk.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to examples and the accompanying drawings, and the exemplary embodiments and descriptions thereof are only used for explaining the present invention and are not used as limiting the present invention.
Example 1
As shown in fig. 1, this embodiment 1 provides a method for implementing communication between the internet and the local area network based on the Http protocol, which includes the following steps:
s1, receiving an HTTP request at a front-end server, coding corresponding message data into binary data streams, and storing the binary data streams in a request table of a database through a JDBC interface;
s2, after the post-positioned server reads the binary data stream in the database request table, establishing connection with a target server, sending the binary data stream to the target server, and waiting for the target server to return response data;
s3, encoding the response data into binary data stream by the rear server, and storing the binary data stream into a response table of the database through the JDBC interface;
and S4, after the front-end server reads the binary data stream in the database response table, sending the binary data stream to the client.
As shown in fig. 2, in a specific embodiment, the processing of the Http request by the front end server includes the following steps:
f1, establishing TCP connection with a bottom layer by utilizing Netty, receiving an Http request sent by the Internet, decoding corresponding message data by utilizing a Netty self-contained decoding tool Http request decoder to obtain a request message, and sending the request message to an Http request processing module, wherein the message data is a binary data stream;
f2, the Http request processing module receives the request message, distributes a request ID for the request message, and performs security check on the URI and Token in the request message by using a universal encryption algorithm HmacSha 256;
f3, coding the received request message by utilizing a Netty self-contained tool Embedded channel and an HttpRequestEncoder to obtain a request binary data stream;
f4, creating a custom Protobuf protocol message request Chunk instance for storing a request ID, a message index and a request binary data stream;
f5, sending the created request Chunk instance to a queue of a database data exchange module;
f6, the database data exchange module receives the request Chunk instance, creates a custom Protobuf protocol message request Payload instance, and stores the request Chunk instance into the request Payload instance;
f7, calculating whether the space occupied by the binary data stream after the current request Payload instance is coded is less than 64KB;
f71, if the space occupied by the binary data stream after the current request Payload instance is coded is less than 64KB, checking whether a next request Chunk instance exists;
if the next request Chunk instance does not exist, encoding the request Payload instance to obtain a request Payload binary data stream, and calling the JDBC interface to store the request Payload binary data stream in a request table of the database;
judging whether a request Chunk instance waiting to be sent to the database data exchange module exists or not, and if so, repeating F6; if not, executing G1;
if the next request Chunk instance exists, checking whether the remaining space of the request Payload instance is enough to store the next request Chunk instance;
f711, if sufficient, saving the next request Chunk instance to the request Payload instance, and repeating F7;
f712, if the number of the request Payload instances is insufficient, encoding the request Payload instances to obtain a request Payload binary data stream, and calling a JDBC interface to store the request Payload binary data stream in a request table of a database;
judging whether a request Chunk instance waiting to be sent to the database data exchange module exists or not, and if so, repeating the step F6; if not, executing G1;
f72, if the space occupied by the binary data stream after the current request Payload instance is coded is larger than or equal to 64KB, coding the request Payload instance to obtain the request Payload binary data stream, and calling the JDBC interface to store the request Payload binary data stream in a request table of the database;
judging whether a request Chunk instance waiting to be sent to the database data exchange module exists or not, and if so, repeating F6; if not, G1 is executed.
As shown in fig. 3, in a specific embodiment, in the front-end server, if an error occurs in Http request processing, a request message or a response message is encoded into a binary data stream and sent to a client, where the error in Http request processing includes the following cases: JDBC interface connection error, storage failure, storage overtime, query return overtime, etc.
In a specific embodiment, the step of processing the Http request by the backend server includes the following steps:
g1, inquiring a request table of the database, if the binary data stream exists in the request table, reading the request Payload binary data stream in the request table, and deleting the read request Payload binary data stream in the request table.
G2, decoding the read request Payload binary data stream to obtain a request Payload instance, reading the request Chunk instance from the request Payload instance, searching or creating an Http request processing module instance according to the request ID in the request Chunk instance, and sending the request Chunk instance to the corresponding Http request processing module instance according to the request ID;
g3, in the Http request processing module example, sequencing the request Chunk examples according to the message indexes in the request Chunk examples, and trying to send request binary data streams;
g4, sending request binary data streams according to the arrangement sequence, acquiring a request Chunk instance from 0 by a message index, taking out the request binary data streams and sending the request binary data streams to an Http message transceiver module; until the message index is interrupted or the request binary data stream in the last request Chunk instance is sent;
g41, if the index of the message in the previous step is interrupted, waiting for receiving the request binary data stream in the next request Chunk instance, and repeating G4 after receiving the request binary data stream in the next request Chunk instance;
g42, if the sending of the binary data stream of the request in the last Chunk requesting example is finished, recovering and releasing resources used in the Http request processing module, occupying a memory of the post-server after the Http request processing module processes the data, and reducing the memory pressure of the post-server by recovering and releasing the memory of the post-server occupied when the Http request processing module processes the data;
and G5, the Http message transceiving module receives the request binary data stream, establishes connection with the target server by utilizing Netty, and sends the request binary data stream to the target server.
As shown in fig. 4, in a specific embodiment, the step of processing the Http response by the backend server includes the following steps:
h1, after receiving the request binary data stream, the target server returns response data, the Netty self-contained response decoding tool HttpResponseDecoder decodes the response data to obtain a response message, and sends the response message to the Http request processing module, wherein the response data is the binary data stream;
the H2 and Http request processing module receives the response message, encodes the response message by utilizing a Netty self-contained tool Embedded channel and a Http responseEncoder, and obtains a response binary data stream;
h3, creating a self-defined Protobuf protocol message response Chunk instance, storing a request ID, a message index and a response binary data stream, and sending the response Chunk instance to a database data exchange module;
h4, the database data exchange module receives the response Chunk instance, and creates a self-defined Protobuf protocol message response Payload instance for storing the response Chunk instance;
h5, calculating whether the space occupied by the binary data stream after the current response Payload example is coded is less than 64KB;
h51, if the space occupied by the binary data stream after the current response Payload instance is coded is less than 64KB, checking whether a next response Chunk instance exists;
if the next response Chunk instance does not exist, coding the response Payload instance to obtain a response Payload binary data stream, calling the JDBC interface to store the response Payload binary data stream in a response table of the database, judging whether a response Chunk instance waiting to be sent to the database data exchange module exists or not, and if so, repeating H4; if not, executing I1;
if the next response Chunk instance exists, checking whether the remaining space of the response Payload instance is enough to store the next response Chunk instance;
h511, if sufficient, saving the next response Chunk instance to the response Payload instance, and repeating H5;
h512, if the answer is insufficient, encoding the response Payload instance to obtain a response Payload binary data stream, calling the JDBC interface to store the response Payload binary data stream in a response table of the database, judging whether a response Chunk instance waiting to be sent to the database data exchange module exists or not, and if the response Chunk instance exists, repeating H4; if not, executing I1;
h52, if the space occupied by the binary data stream coded by the current response Payload instance is larger than or equal to 64KB, coding the response Payload instance to obtain a response Payload binary data stream, calling the JDBC interface to store the response Payload binary data stream in a response table of the database, judging whether a response Chunk instance waiting to be sent to the database data exchange module exists or not, and if yes, repeating H4; if not, I1 is executed.
As shown in fig. 5, in a specific embodiment, the processing, by the front-end server, of the Http response includes the following steps:
i1, inquiring a response table of the database, if the response table has binary data streams, reading the response Payload binary data streams in the response table, and deleting the read response Payload binary data streams in the response table.
I2, decoding the read response Payload binary data stream to obtain a response Payload instance, reading a response Chunk instance from the response Payload instance, and sending a message to a corresponding instance of the Http request processing module according to a request ID in the response Chunk instance;
i3, in the Http request processing module example, sorting the response Chunk example by using the message index in the response Chunk example, and trying to send a response binary data stream;
i4, sending response binary data streams according to the arrangement sequence, acquiring a response Chunk instance from 0 by a message index, taking out the response binary data streams and sending the response binary data streams to an Http message transceiving module; until the message index is interrupted or the response binary data stream in the last response Chunk instance is sent;
i41, if the message index in the previous step is interrupted, waiting for receiving the response binary data stream in the next response Chunk instance, and repeating I4 after receiving the response binary data stream in the next response Chunk instance;
i42, if the sending of the response binary data stream in the last response Chunk instance is finished, recovering and releasing resources used in the Http request processing module, wherein the Http request processing module occupies the memory of the front-end server after processing the data, and the front-end server memory occupied by the Http request processing module when processing the data is recovered and released, so that the memory pressure of the front-end server is reduced;
and the I5 and Http message transceiving modules receive the response binary data stream and send the response binary data stream to the client through the TCP connection.
In a specific embodiment, the example of the custom Protobuf protocol message Payload includes: the method is used for storing the protocol types of the database and aggregating packet Http message messages, and the size of each data packet is ensured to be 64KB as far as possible.
The foregoing custom protocol message Chunk instance: the method is used for Http message transmission and recording the request, the message index and Http original message data.
In a specific embodiment, the method for realizing communication between the internet and the local area network is realized by generating a self-defined protocol code by using a protobuf tool protoc provided by Google, and the generated code file comprises a data coding and decoding method.
As shown in fig. 7, in a specific embodiment, the Chunk instance is composed of two parts, where the first part is the Chunk instance tag, i.e. the ranking number; the second part comprises a stored request ID, a message index and a binary data stream; the Payload instance is used for aggregating the Chunk instances, and sorting the response Chunk instances according to the message indexes in the Chunk instances.
In a specific embodiment, the request table and the response table of the database have the following structures: only contains one field of Chunk instance, and the field type is Blob. The front-end server and the back-end server are based on a Google Protobuf custom communication protocol, data are coded into binary data streams to be stored during storage, and the binary data are decoded into Protobuf protocol message objects during reading.
Example 2
As shown in fig. 6, this embodiment 2 provides a system for implementing communication between the internet and the local area network based on the Http protocol, and is used to implement the method for implementing communication between the internet and the local area network provided in embodiment 1, where the front-end server and the back-end server include an Http messaging module, an Http request processing module, a database data exchange module, and the system further includes a database, where the database is used as a middleware and is used to interface the database data exchange modules of the front-end server and the back-end server;
the Http message transceiver module in the front-end server establishes a TCP connection with a bottom layer in the internet based on Netty, and is in butt joint with the Http request processing module, the Http request processing module is in butt joint with the database data exchange module and the Http message transceiver module, and the database data exchange module is in butt joint with the database and the Http request processing module;
the database data exchange module in the rear server is in butt joint with the database and the Http request processing module, the Http request processing module is in butt joint with the database data exchange module and the Http message receiving and sending module, and the Http message receiving and sending module establishes a TCP connection with a server in a local area network based on Netty.
In a specific embodiment, only one Http message transceiving module and one database data exchange module exist in a front-end server or a rear-end server; the Http request processing module comprises a plurality of Http request processing module instances, and each Http request has a corresponding Http request processing module instance.
In a specific embodiment, the Http messaging module in the front-end server,
the method comprises the steps that TCP connection is established between the Netty and the bottom layer and used for receiving an Http request sent by the internet, the corresponding message data is decoded by using a Netty self-contained decoding tool Http request decoder to obtain a request message, and the request message is sent to an Http request processing module; or receiving the response binary data stream, and sending the response binary data stream to the client through the TCP connection; or, when the Http request processing has an error, the request message or the response message is encoded into a binary data stream and sent to the client.
In particular embodiments, the Http request processing module in the front-end server,
the system comprises a request message receiving module, a request ID module and a security check module, wherein the request message receiving module is used for receiving the request message, distributing the request ID to the request message and carrying out security check on the request message; coding the request message to obtain a request binary data stream, creating a request Chunk instance, storing a request ID, a message index and the request binary data stream, and sending the request Chunk instance to a queue of a database data exchange module; or, the response Chunk instances are sorted by using the message indexes in the response Chunk instances, and attempt to send response binary data streams, and the response binary data streams are sent to the Http message transceiver module according to the sorting order.
In a specific embodiment, the database data exchange module in the front-end server,
the request table is used for receiving a request Chunk instance, creating a request Payload instance, storing the request Chunk instance into the request Payload instance, encoding the request Payload instance to obtain a request Payload binary data stream, and storing the request Payload binary data stream in a database; or reading the response Payload binary data stream, decoding the response Payload binary data stream to obtain a response Payload instance, reading the response Chunk instance from the response Payload instance, and sending the message to the corresponding Http request processing module instance according to the request ID in the response Chunk instance.
In particular embodiments, a database data exchange module in a back-end server,
the request Payload binary data stream in the request table is read and decoded to obtain a request Payload instance, the request Chunk instance is read from the request Payload instance, the Http request processing module instance is searched or created according to the request ID in the request Chunk instance, and the request Chunk instance is sent to the corresponding Http request processing module instance according to the request ID; or receiving a response Chunk instance, creating a response Payload instance, and storing the response Chunk instance; and coding the response Payload instance to obtain a response Payload binary data stream, and storing the response Payload binary data stream in a response table of the database.
In particular embodiments, the Http request handling module in the backend server,
the system comprises a request Chunk instance, an Http message receiving and sending module, a Http message sending and receiving module and a data processing module, wherein the request Chunk instance is used for sequencing the request Chunk instance by using a message index in the request Chunk instance, sending a request binary data stream according to a sequence and sending the request binary data stream to the Http message receiving and sending module; or receiving the response message, encoding the response message to obtain a response binary data stream, creating a response Chunk instance, storing the request ID, the message index and the response binary data stream, and sending the response Chunk instance to the database data exchange module.
In a specific embodiment, the Http messaging module in the backend server,
the system comprises a target server, a network server and a server, wherein the target server is used for receiving a request binary data stream, establishing connection with the target server by utilizing Netty and sending the request binary data stream to the target server; or decoding the response data by utilizing Netty to obtain a response message, and sending the response message to the Http request processing module.
Example 3
This embodiment 3 provides an unmanned aerial vehicle application of taking photo by plane: this application utilizes unmanned aerial vehicle to shoot equipment and carries out equipment detection, and it has very huge advantage to the place unmanned aerial vehicle aerial photograph that many manual works are difficult to arrive, for example: the unmanned aerial vehicle aerial photographing system has the advantages that the electric tower on the top of a mountain is required to ascend and descend the mountain and climb the tower through manual inspection, time and labor are consumed, the unmanned aerial vehicle is very dangerous, the inspection speed is high, the unmanned aerial vehicle is not dangerous, the unmanned aerial vehicle is required to be accurately positioned through a network RTK (real-time kinematic) and can only be connected through the Internet, so that the unmanned aerial vehicle aerial photographing work can only be manually controlled by the unmanned aerial vehicle to perform photographing inspection before the unmanned aerial vehicle aerial photographing system is used, then the unmanned aerial vehicle aerial photographing operation is guided into an isolated system in an enterprise or a mechanism local area network through a USB flash disk, the use is inconvenient, the manual work load is large, the data error is very easily caused, and the maintenance is difficult; after the invention is used, the Internet and a mechanism local area network with a safety isolation hardware device can be opened, a patrol task is sent inside, the unmanned aerial vehicle patrol and the patrol task are automatically controlled to be associated, the data return work is completed, the data is not required to be imported manually, the Internet RTK can be used for accurate positioning, the error caused by manually comparing the data is avoided, the workload is greatly reduced, and the patrol cost is reduced.
The above-mentioned embodiments, objects, technical solutions and advantages of the present invention are further described in detail, it should be understood that the above-mentioned embodiments are only examples of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (7)

1. An implementation method for communication between the internet and a local area network based on an Http protocol is characterized by comprising the following steps:
s1, receiving an HTTP request at a front-end server, encoding corresponding message data into binary data streams, and storing the binary data streams in a request table of a database through a JDBC interface;
s2, after the post-positioned server reads the binary data stream in the database request table, establishing connection with a target server, sending the binary data stream to the target server, and waiting for the target server to return response data;
s3, encoding the response data into binary data stream by the rear server, and storing the binary data stream into a response table of the database through the JDBC interface;
s4, after the front-end server reads the binary data stream in the database response table, sending the binary data stream to the client;
after the front-end server receives the Http request, the method encodes the corresponding message data into a binary data stream, and comprises the following steps:
a1, decoding corresponding message data to obtain a request message;
a2, distributing a request ID, and carrying out security check on the URI and Token in the request message;
a3, coding the request message to obtain a request binary data stream;
at the front-end server, storing the binary data stream in a request table of a database, comprising the steps of:
b1, creating a request Chunk instance, which is used for storing a request ID, a message index and a request binary data stream;
b2, creating a request Payload instance for storing the request Chunk instance;
b3, coding the request Payload example to obtain a request Payload binary data stream, and storing the request Payload binary data stream in a request table of a database;
after reading the binary data stream in the database request table, the post-positioned server establishes connection with the target server and sends the binary data stream to the target server, and the method comprises the following steps:
decoding the read request Payload binary data stream to obtain a request Payload instance, reading the request Chunk instance, creating a corresponding Http request processing module instance according to the request ID in the request Chunk instance, sequencing the request Chunk instance according to the message index in the request Chunk instance in the Http request processing module instance, and sending the request binary data stream to a target server in sequence.
2. The method of claim 1, wherein the step of encoding the response data into a binary data stream at the post-server, and storing the binary data stream in a response table of a database via a JDBC interface comprises the steps of:
c1, after receiving the request binary data stream, the target server returns response data, and the post-positioned server decodes the response data to obtain a response message;
c2, coding the response message to obtain a response binary data stream;
c3, creating a response Chunk instance for storing the request ID, the message index and the response binary data stream;
c4, creating a response Payload instance for storing a response Chunk instance;
and C5, encoding the response Payload example to obtain a response Payload binary data stream, and storing the response Payload binary data stream in a response table of the database.
3. The method for implementing communication between the internet and the local area network based on the Http protocol as claimed in claim 2, wherein the step of sending the binary data stream to the client after the pre-server reads the binary data stream in the database response table comprises the steps of:
decoding the read response Payload binary data stream to obtain a response Payload example; reading the response Chunk instance, searching the corresponding Http request processing module instance according to the request ID in the response Chunk instance, sequencing the response Chunk instance according to the message index in the response Chunk instance in the Http request processing module instance, and sending the response binary data stream to the client in sequence.
4. The method as claimed in claim 2, wherein if the request is wrong, the front-end server encodes the request message or the response message into binary data and sends the binary data to the client.
5. The method as claimed in claim 1, wherein the step of requesting the Payload binary data stream to be stored in a request table of a database comprises the steps of:
d1, calculating whether the space occupied by the coded request Payload instance is less than 64KB;
d11, if the space occupied by the request Payload instance after encoding is less than 64KB, checking whether the remaining space of the request Payload instance can store the next request Chunk instance;
d111, if yes, saving the next request Chunk instance into the request Payload instance, and repeating D1;
d112, if the request Payload instance cannot be encoded, obtaining a request Payload binary data stream, and calling a JDBC interface to store the request Payload binary data stream in a request table;
and D12, if the space occupied by the request Payload instance after encoding is larger than or equal to 64KB, encoding the request Payload instance to obtain a request Payload binary data stream, and calling the JDBC interface to store the request Payload binary data stream in a request table.
6. The method as claimed in claim 2, wherein the response Payload binary data stream is stored in a response table of a database, and the method comprises the following steps:
e1, calculating whether the space occupied by the coded response Payload example is less than 64KB;
e11, if the space occupied by the coded response Payload instance is less than 64KB, checking whether the residual space of the response Payload instance can store the next response Chunk instance;
e111, if yes, saving the next response Chunk instance into the response Payload instance, and repeating E1;
e112, if the response Payload instance cannot be obtained, encoding the response Payload instance to obtain a response Payload binary data stream, and calling a JDBC interface to store the response Payload binary data stream in a response table;
and E12, if the space occupied by the response Payload instance after encoding is larger than or equal to 64KB, encoding the response Payload instance to obtain a response Payload binary data stream, and calling the JDBC interface to store the response Payload binary data stream in a response table.
7. The method as claimed in claim 1, wherein the binary data stream in the database request table or the response table is deleted after reading the binary data stream in the database request table or the response table.
CN202210013782.7A 2022-01-06 2022-01-06 Method for realizing communication between Internet and local area network based on Http protocol Active CN114363312B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210013782.7A CN114363312B (en) 2022-01-06 2022-01-06 Method for realizing communication between Internet and local area network based on Http protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210013782.7A CN114363312B (en) 2022-01-06 2022-01-06 Method for realizing communication between Internet and local area network based on Http protocol

Publications (2)

Publication Number Publication Date
CN114363312A CN114363312A (en) 2022-04-15
CN114363312B true CN114363312B (en) 2022-11-22

Family

ID=81107948

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210013782.7A Active CN114363312B (en) 2022-01-06 2022-01-06 Method for realizing communication between Internet and local area network based on Http protocol

Country Status (1)

Country Link
CN (1) CN114363312B (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075527A (en) * 2010-12-30 2011-05-25 合肥恒卓科技有限公司 Internet data communication system and communication method thereof
US9350763B1 (en) * 2012-04-17 2016-05-24 Amazon Technologies, Inc. HTTP tunnelling over websockets
CN105956188A (en) * 2016-06-07 2016-09-21 浪潮电子信息产业股份有限公司 Method for exporting and importing binary files among different types of databases
CN108234451A (en) * 2017-12-11 2018-06-29 厦门亿力吉奥信息科技有限公司 Electric power intranet and extranet request forwarding Proxy Method and computer readable storage medium
CN111698334B (en) * 2020-06-24 2023-04-07 昆明东电科技有限公司 Network service method and system of dual reverse proxy between intranet and extranet

Also Published As

Publication number Publication date
CN114363312A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
CN107749840B (en) One-way data secure transmission and cooperative processing system and method based on one-way gatekeeper
CN109716317B (en) System and method for creating a time accurate event stream
CN103581230A (en) File transmission system and method, receiving end and sending end
CN1625179B (en) Send by reference in a customizable, tag-based protocol
CN110741573A (en) Method and system for selectively propagating transactions using network coding in a blockchain network
CN102355426A (en) Method for transmitting off-line file and system
CN102890631A (en) Method for transmitting message based on persistent message queue and message transmission device
CN112822260B (en) File transmission method and device, electronic equipment and storage medium
CN110225109B (en) Multi-queue data transmission method based on 'industrial and commercial connection' platform
CN111935227A (en) Method for uploading file through browser, browser and electronic equipment
CN110162512A (en) A kind of log searching method, apparatus and storage medium
CN111382985A (en) To-do message integrated pushing system and working method
CN104462562A (en) Data migration system and method based on data warehouse automation
CN110096381B (en) Method, device, equipment and medium for realizing remote procedure call
CN108614820B (en) Method and device for realizing streaming source data analysis
CN114363312B (en) Method for realizing communication between Internet and local area network based on Http protocol
CN111190963A (en) Block chain application back-end system
CN107204892B (en) Power communication network operation data processing method and device
CN101483653B (en) Method, device and system for providing application layer data to the application layer from network appliances
CN111401819B (en) Intersystem data pushing method and system
CN114139093A (en) Data communication method, equipment and medium
CN110309191B (en) Method, device and system for storing business data
US10623523B2 (en) Distributed communication and task handling to facilitate operations of application system
CN1361609A (en) Network data exchange method and system
CN102420755B (en) Transmission processing method of data message, communication device and system

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