Method, device and electronic equipment for communicating based on a GRPC communication protocol

By implementing the gRPC communication protocol at the kernel layer and utilizing HTTPS connections and encryption, the vulnerability of the gRPC communication protocol to malware is solved, achieving more secure and efficient communication.

CN116192950BActive Publication Date: 2025-11-18戎码科技(北京)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310153797.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-17
Publication Date
2025-11-18
Estimated Expiration
2043-02-17

AI Technical Summary

Technical Problem

The GRPC-based communication protocol is vulnerable to malware, leading to reduced communication security.

Method used

By implementing the gRPC communication protocol at the kernel layer, using HTTPS connections and encryption keys for data transmission, constructing specific data packets to agree on communication protocols and data formats, performing parameter encryption and decryption processing, and recording data stream identifiers to improve communication security and efficiency.

Benefits of technology

It improves the security and efficiency of communication with the server, and reduces the risk of malicious program damage and eavesdropping.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116192950B_ABST
    Figure CN116192950B_ABST
Patent Text Reader

Abstract

The application provides a method, device and electronic equipment for communication based on a GRPC communication protocol, wherein the method comprises the following steps: after a connection is established with a server in a kernel layer, communication data requirements are sent to the server; parameters required by a calling method of the GRPC communication protocol are sent to the server, and the parameters are used to limit the parameters passed by the calling method when communication is performed with the server based on the GRPC communication protocol; a return value based on the calling method fed back by the server is received, the return value is parsed, and return data structure information of the calling method of the GRPC communication protocol is obtained, wherein the return data structure information is used to indicate a data structure standard received from the server when communication is performed with the server based on the GRPC communication protocol; and when communication is performed with the server based on the GRPC communication protocol, the transmitted data is configured according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and more specifically, to a method, apparatus, and electronic device for communication based on the gRPC communication protocol. Background Technology

[0002] Currently, there are many protocols to choose from when clients and servers communicate. For example, the traditional Hypertext Transfer Protocol (HTTP) is widely used by servers, and it's also easier to develop with. However, current gRPC-based communication protocols are vulnerable to malware. Summary of the Invention

[0003] In view of this, the purpose of this application is to provide a method, apparatus and electronic device for communication based on the gRPC communication protocol, so as to improve the problem that the gRPC communication protocol is susceptible to damage by malicious software.

[0004] In a first aspect, embodiments of this application provide a method for communication based on the gRPC communication protocol, including:

[0005] After establishing a connection with the server in the kernel layer, a communication data request is sent to the server.

[0006] Send the parameters required for the calling method of the gRPC communication protocol to the server, wherein the parameters are used to limit the parameters passed by the calling method when communicating with the server based on the gRPC communication protocol;

[0007] The server receives a return value based on the called method, parses the return value, and obtains the return data structure information of the called method of the GRPC communication protocol. The return data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the GRPC communication protocol.

[0008] Specifically, when communicating with the server based on the GRPC communication protocol, the data is transmitted according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements.

[0009] In the above implementation method, by implementing the rules for communication based on the GRPC communication protocol at the kernel layer, it is possible to connect with the server more quickly, and it can also reduce the possibility of being damaged or eavesdropped by other malicious programs, thereby improving the security and efficiency of communication with the server.

[0010] In an optional implementation, the communication data requirements include communication protocol requirements;

[0011] The step of sending a communication data request to the server includes: constructing a phantom data packet that meets the requirements of the communication protocol, and sending the phantom data packet to the server, wherein the phantom data packet is used to indicate the communication protocol used.

[0012] In the above implementation, the protocol standard to be used can be agreed upon with the server in advance, thereby improving the effectiveness of communication with the server based on the GPRC communication protocol.

[0013] In an optional implementation, the communication data requirement includes a frame size requirement; sending the communication data requirement to the server includes: constructing a frame setting packet containing the frame size requirement, and sending the frame setting packet to the server, wherein the frame setting packet is used to indicate the frame size and frame window size of the data transmitted during communication based on the gRPC communication protocol.

[0014] In the above implementation, the frame size and frame window size can be agreed upon with the server in advance, thereby improving the accuracy of communication with the server based on the GPRC communication protocol.

[0015] In an alternative implementation, the communication data requirements include the required stream size;

[0016] The step of sending a communication data request to the server includes: constructing an update window packet containing the data stream size, and sending the update window packet to the server so that the server can update the data stream size of the current connection according to the update window packet.

[0017] In the above implementation, the required size of the current connection stream can be updated in advance with the notification server, thereby improving the success rate of communication with the server based on the gRPC communication protocol.

[0018] In an optional implementation, after establishing a connection with the server, the method further includes: receiving an encryption key sent by the server, the encryption key being used to encrypt data during the communication process;

[0019] Sending the parameters required for the gRPC communication protocol invocation method to the server includes: encrypting the parameters required for the gRPC communication protocol invocation method using the encryption key to obtain encrypted parameters; and sending the encrypted parameters to the server.

[0020] In an optional implementation, the return value is a cryptographic return value; parsing the return value includes: decrypting the cryptographic return value using the encryption key to obtain the return data structure information of the calling method of the GRPC communication protocol.

[0021] In the above embodiments, encrypting the serialized data before transmitting it can improve the security of data transmission.

[0022] In an optional implementation, sending the parameters required for the gRPC communication protocol invocation method to the server includes: sending the parameters required for the gRPC communication protocol invocation method and the interface address to the server, wherein the interface address is used to indicate the communication interface with the server when communicating based on the gRPC communication protocol.

[0023] In an optional implementation, sending the parameters and interface address required for the gRPC communication protocol invocation method to the server includes: serializing the parameters and interface address required for the gRPC communication protocol invocation method to obtain serialized parameters, and sending the serialized parameters to the server;

[0024] The step of receiving the return value based on the calling method sent by the server and parsing the return value to obtain the return data structure information of the calling method of the GPRC communication protocol includes: deserializing the return value to obtain the return data structure information of the calling method of the GPRC communication protocol.

[0025] In an optional implementation, the method further includes: obtaining a data stream identifier; constructing a sequential sequence based on the data stream identifier, wherein the sequential sequence is used to record the position of the data stream communicating with the server.

[0026] Secondly, embodiments of this application also provide an apparatus for communication based on the GRPC communication protocol, comprising:

[0027] The first sending module is used to send communication data requests to the server after establishing a connection with the server in the kernel layer;

[0028] The second sending module is used to send the parameters required for the calling method of the GRPC communication protocol to the server, wherein the parameters are used to limit the parameters passed by the calling method when communicating with the server based on the GRPC communication protocol;

[0029] The parsing module is used to receive the return value based on the calling method from the server, parse the return value to obtain the return data structure information of the calling method of the GPRC communication protocol, wherein the return data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the GPRC communication protocol; wherein, when communicating with the server based on the GPRC communication protocol, the data is transmitted according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements.

[0030] Thirdly, embodiments of this application also provide an electronic device, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the above-described method.

[0031] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described method.

[0032] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, specific embodiments are described below in conjunction with the accompanying drawings. Attached Figure Description

[0033] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0034] Figure 1 A schematic diagram illustrating the interaction between a server and a client terminal provided in an embodiment of this application;

[0035] Figure 2 A block diagram illustrating an electronic device provided in an embodiment of this application;

[0036] Figure 3 A flowchart illustrating a method for communication based on the GRPC communication protocol provided in this application embodiment;

[0037] Figure 4 A schematic diagram of the functional modules of a device for communication based on the GRPC communication protocol provided in an embodiment of this application. Detailed Implementation

[0038] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0039] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0040] Currently, the communication method based on the gRPC communication protocol is relatively common on the server side and is easy to develop.

[0041] However, the inventors of this application have learned through research that while communication methods based on the gRPC communication protocol have the aforementioned advantages, they also suffer from vulnerability to malicious software. The main reason for this vulnerability is that clients using the gRPC communication protocol can only use user-level support libraries for connection and communication. However, the user-level implementation is susceptible to malware attack, which can even allow malware to obtain and tamper with communication content. Furthermore, existing programs that use the gRPC communication protocol for network communication run at the user level, making them highly vulnerable to malicious programs that can damage and modify them, significantly reducing communication security.

[0042] Based on the above research, this application provides a method for communication based on the gRPC communication protocol. This method achieves the function of communication based on gRPC at the Windows kernel layer by implementing the relevant protocol content of HTTP2 and gRPC from the bottom layer, thereby improving the communication speed and greatly improving the communication security.

[0043] The following section introduces the concepts involved in this application before describing the communication method based on the GRPC communication protocol provided in this application:

[0044] GRPC: short for Google Remote Procedure Call, is a high-performance, general-purpose, open-source remote procedure call framework developed by Google, primarily designed based on the HTTP / 2 protocol standard;

[0045] HTTP / 2: Hypertext Transfer Protocol version 2.0, which specifies the format of messages transmitted between clients and servers;

[0046] Kernel layer: It has the highest execution privileges and is at the same level as the system kernel code, but the APIs (Application Program Interfaces) and types provided by the system are subject to certain restrictions;

[0047] User layer: The layer where user applications reside. The system provides a rich set of interfaces and types, so problems will not affect the operation of the system.

[0048] To facilitate understanding of this embodiment, the operating environment for implementing the communication method based on the GRPC communication protocol disclosed in this application embodiment will be described in detail first.

[0049] like Figure 1 The diagram illustrates the interaction between a server 110 and a client terminal 120 according to an embodiment of this application. The server 110 establishes a communication connection with one or more client terminals 120 via a network for data communication or interaction. The server 110 can be a web server, a database server, etc. The client terminal 120 can be a personal computer (PC), tablet computer, smartphone, personal digital assistant (PDA), etc.

[0050] In this embodiment, the client terminal 120 may have a client running on it.

[0051] Server 110 can run a server-side component that can receive data from clients and establish a GRPC communication protocol with them to enable communication based on the GRPC protocol.

[0052] like Figure 2 The diagram shown is a block illustration of an electronic device. The electronic device 200 may include a memory 211 and a processor 213. Those skilled in the art will understand that... Figure 2 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device 200. For example, the electronic device 200 may also include components that are more... Figure 2 The more or fewer components shown, or having the same Figure 2 The different configurations shown.

[0053] For example, Figure 1 The server 110 and client terminal 120 shown may include Figure 2 The components of the electronic device 200 shown can, of course, include more than [other components] if there are additional functional requirements. Figure 2 The electronic device shown has 200 more components.

[0054] The memory 211 and processor 213 described above are electrically connected directly or indirectly to enable data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The processor 213 described above is used to execute executable modules stored in the memory.

[0055] The memory 211 can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory 211 stores programs, and the processor 213 executes these programs upon receiving execution instructions. The methods executed by the electronic device 200, as defined in any embodiment of this application, can be applied to or implemented by the processor 213.

[0056] The aforementioned processor 213 may be an integrated circuit chip with signal processing capabilities. The processor 213 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a digital signal processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor.

[0057] The electronic device 200 in this embodiment can be used to execute various steps in the various methods provided in the embodiments of this application. The implementation process of the method for communication based on the gRPC communication protocol is described in detail below through several embodiments.

[0058] Please see Figure 3 This is a flowchart illustrating a method for communication based on the gRPC communication protocol provided in an embodiment of this application. The method for communication based on the gRPC communication protocol provided in this embodiment can be applied to the above-mentioned... Figure 1 Specifically, the client terminal shown runs a client application, which can be used to execute the steps in the communication method based on the GPRC communication protocol provided in this embodiment. The following will describe... Figure 3 The specific process shown will be explained in detail.

[0059] Step 310: After establishing a connection with the server in the kernel layer, send a communication data request to the server.

[0060] In this embodiment, an HTTPS connection can be established with the server at the kernel layer, and a handshake can be performed with the server.

[0061] After establishing a connection with the server at the kernel level, you can receive the encryption key sent by the server. The encryption key is used to encrypt data during communication with the server.

[0062] In this embodiment, when establishing an HTTPS connection with the server, the client can also specify a server interface address, which is used to receive data during subsequent communication between the client and the server based on the gRPC communication protocol.

[0063] For example, a handshake with the server can be used to implement the full handshake phase over HTTPS.

[0064] For example, if the client terminal uses Windows as its operating system, then the client can establish an HTTPS connection with the server and perform a handshake with the server in the Windows kernel layer.

[0065] Optionally, the communication data request can be transmitted to the server in the form of a data packet. Therefore, before performing step 310, a data packet containing the communication data request can be constructed.

[0066] After receiving the data packet, the server can obtain the communication data request by parsing the data packet.

[0067] For example, the communication data requirements may include requirements for the size of the communication data frame, requirements for the communication protocol standard, etc.

[0068] Each communication data request can be constructed as a separate data packet and sent to the server; alternatively, all communication data requests can be packaged into a single resource data packet and sent to the server.

[0069] This resource data packet can be used to notify the server of the requirements of the GRPC communication protocol for this construction.

[0070] Step 320: Send the parameters required for calling the GRPC communication protocol to the server.

[0071] The parameters required for this calling method can be set by the user as needed before establishing the gRPC communication protocol with the server. Understandably, different use cases require different calling methods from the server, and the content of these required parameters will also differ depending on the required calling method. These parameters are predefined.

[0072] In this embodiment, the parameters required for calling the gRPC communication protocol and the interface address can also be sent to the server. The interface address indicates the communication interface with the server when communicating based on the gRPC communication protocol.

[0073] Step 330: Receive the return value from the server based on the method call, parse the return value, and obtain the return data structure information of the method call of the GPPC communication protocol.

[0074] The return value of this calling method represents the information returned by the server's calling method when communicating based on the GPRC communication protocol. The specific content of this return value can be determined by the user through the agreed-upon parameters returned by the server when calling the server's calling method based on the GPRC communication protocol. Specifically, the content of this return value can be agreed upon according to actual needs. It is worth noting that the agreed-upon return value may differ depending on the usage environment of the GPRC communication protocol and the specific calling method.

[0075] The returned data structure information can be obtained by parsing the return value. This returned data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the gRPC communication protocol.

[0076] When the client and server communicate subsequently based on the GRPC communication protocol, after the client calls the server's calling method, the server returns data in the format agreed upon above for the returned data structure information.

[0077] Through steps 310 to 330 above, the agreement on the communication method based on the GRPC communication protocol can be realized.

[0078] After completing the agreement on the communication method based on the GRPC communication protocol in steps 310 to 330 above, the current data stream can be kept open as needed. With the current data stream open, the client can listen to the push sent by the server, and the client can also continue to call the required remote call method using the current data stream.

[0079] Steps 310 to 330 above can implement the conventions of the gRPC communication protocol at the kernel level, which can enable faster connection with the server, reduce the possibility of being damaged or eavesdropped by other malicious programs, and improve the security and efficiency of communication with the server.

[0080] Depending on actual needs, the communication data requirements involved in step 310 above may include at least the following situations.

[0081] In one implementation, the communication data requirement includes a communication protocol requirement, and the data packet may include a phantom data packet. The phantom data packet is a phantom data packet that satisfies the communication protocol requirement. Step 310 described above may include: constructing a phantom data packet that satisfies the communication protocol requirement and sending the phantom data packet to the server, the phantom data packet indicating the communication protocol used.

[0082] The phantom packet is used to indicate the communication protocol used. For example, the phantom packet is used to inform the server that the current client is using the HTTP protocol standard.

[0083] In this embodiment, the phantom data packet can also be represented as a Magic data packet.

[0084] For example, the current client may be using the HTTP protocol standard HTTP2.

[0085] In another embodiment, the communication data requirement includes a frame size requirement, and the data packet may include a frame setting packet; step 320 above may include: constructing a frame setting packet containing the frame size requirement and sending the frame setting packet to the server.

[0086] This frame settings packet is used to indicate the frame size and frame window size of the data transmitted during communication based on the gRPC communication protocol.

[0087] For example, the frame size and frame window size defined by the frame settings packet can be the frame size and frame window size currently used by the client in the communication.

[0088] In another implementation, the communication data requirement includes the required size of the data stream, and the data packet may include an update window packet. Step 310 above may include: constructing an update window packet containing the data stream size, and sending the update window packet to the server so that the server updates the data stream size of the current connection according to the update window packet.

[0089] By using the above method, the server can be informed of the relevant limitations of data transmission in the GRPC communication protocol through interaction with the server. The relevant limitations of data transmission can be adaptively agreed upon, so that the communication method based on the GRPC communication protocol provided in this embodiment can adapt to more usage scenarios and improve the applicability of the communication method based on the GRPC communication protocol.

[0090] To improve the security of the communication method based on the gRPC communication protocol during the protocol agreement process, the transmitted parameters can be encrypted. Therefore, before step 320, the method may further include: receiving an encryption key sent by the server, which is used to encrypt data during the communication process.

[0091] Step 320 may include: using the encryption key to encrypt the parameters required for calling the GRPC communication protocol method, obtaining encrypted parameters, and sending the encrypted parameters to the server.

[0092] For example, the encryption key mentioned above can be a symmetric encryption key. After receiving the encryption parameters, the server can use the key to decrypt the encryption parameters, and then deserialize the decrypted data to obtain the parameters required by the calling method when communicating based on the gRPC communication protocol.

[0093] For example, the return value obtained from the server can be a cryptographic return value. Step 330 above may include: decrypting the cryptographic return value using the encryption key to obtain the return data structure information of the calling method of the gRPC communication protocol.

[0094] To enable the server to more successfully obtain the parameters required for the client's agreed-upon method call, the parameters and interface address of the gRPC communication protocol transmitted to the server can be serialized before being sent to the server. Therefore, step 320 may include serializing the data structure of the method call parameters and the server interface address to obtain serialized parameters, and then sending these serialized parameters to the server.

[0095] Serialization is the process of converting parameters that need to be transmitted to the server into a form that can be stored or transmitted. Parameters after serialization can be binary data.

[0096] In this embodiment, serialization parameters are sent to the server through an HTTPS connection established with the server.

[0097] In this embodiment, after obtaining the serialization parameter, the server can perform deserialization processing to obtain the parameters required for the calling method agreed upon by the client.

[0098] Optionally, after serialization, the serialization parameters can be encrypted using the aforementioned encryption key, and the encrypted serialization parameters can be sent to the server.

[0099] In this embodiment, after obtaining the serialization parameters of the encrypted state, the server can first perform decryption processing and then deserialization processing to obtain the parameters required for the calling method agreed upon by the client.

[0100] In this embodiment, if the data sent to the server in step 320 is serialized data, then the return value returned by the server to the client can also be a serialized return value. Based on this, step 330 may include: deserializing the return value to obtain the return data structure information of the calling method of the gRPC communication protocol.

[0101] Alternatively, the return value can be obtained by the server through serialization followed by encryption. Based on this, when the client receives the return value, it can first decrypt it and then deserialize it to obtain the parameters required by the client's agreed-upon method call.

[0102] In this embodiment, in order to better track and record the communication process with the server based on the GRPC communication protocol, the method for communication based on the GRPC communication protocol may further include: constructing a data stream identifier.

[0103] In this embodiment, a sequential sequence can be constructed based on the data stream identifier, wherein the sequential sequence is used to record the position of the data stream communicating with the server.

[0104] For example, the initial value of the sequential sequence can be zero, and the sequential sequence can be incremented by one each time the client communicates with the server via the gRPC communication protocol.

[0105] This embodiment provides a method for communication based on the gRPC communication protocol, which can directly perform communication based on the gRPC communication protocol at the kernel level. This allows for more efficient connection with the server while reducing the risk of damage and eavesdropping by other malicious programs, thus greatly improving communication security.

[0106] Based on the same application concept, this application also provides an apparatus for communication based on the GRPC communication protocol, which corresponds to the method for communication based on the GRPC communication protocol. Since the principle of the apparatus in this application is similar to that of the aforementioned method for communication based on the GRPC communication protocol, the implementation of the apparatus in this application can refer to the description in the above-mentioned method embodiments, and the repeated parts will not be described again.

[0107] Please see Figure 4 This is a functional module diagram of an apparatus for communication based on the gRPC communication protocol provided in this application embodiment. Each module in the apparatus for communication based on the gRPC communication protocol in this embodiment is used to execute the steps in the above method embodiments. The apparatus for communication based on the gRPC communication protocol includes: a first sending module 410, a second sending module 420, and a parsing module 430; the contents of each module are as follows:

[0108] The first sending module 410 is used to send a communication data request to the server after establishing a connection with the server in the kernel layer;

[0109] The second sending module 420 is used to send the parameters required for the calling method of the GRPC communication protocol to the server, wherein the parameters are used to limit the parameters passed by the calling method when communicating with the server based on the GRPC communication protocol;

[0110] The parsing module 430 is used to receive the return value based on the calling method from the server, parse the return value to obtain the return data structure information of the calling method of the GRPC communication protocol, wherein the return data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the GRPC communication protocol; wherein, when communicating with the server based on the GRPC communication protocol, the data is transmitted according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements.

[0111] In one possible implementation, the communication data requirement includes communication protocol requirements;

[0112] The first sending module 410 is used to construct a phantom data packet that meets the requirements of the communication protocol and send the phantom data packet to the server. The phantom data packet is used to indicate the communication protocol used.

[0113] In one possible implementation, the communication data requirements include frame size requirements;

[0114] The first sending module 410 is used to construct a frame setting packet containing the frame size requirement and send the frame setting packet to the server. The frame setting packet is used to indicate the frame size and frame window size of the data transmitted during communication based on the GPPC communication protocol.

[0115] In one possible implementation, the communication data requirement includes the data stream size;

[0116] The first sending module 410 is used to construct an update window packet containing the data stream size and send the update window packet to the server so that the server can update the data stream size of the current connection according to the update window packet.

[0117] In one possible implementation, the apparatus for communication based on the GRPC communication protocol may further include: a receiving module for receiving an encryption key sent by the server, the encryption key being used to encrypt data during the communication process;

[0118] The second sending module 420 is used to encrypt the parameters required for calling the GRPC communication protocol using the encryption key to obtain encrypted parameters; and then sends the encrypted parameters to the server.

[0119] In one possible implementation, the return value is a closed-state return value;

[0120] The parsing module is also used to decrypt the encrypted return value using the encryption key to obtain the return data structure information of the calling method of the GRPC communication protocol.

[0121] In one possible implementation, the second sending module 420 is used to send the parameters required for the calling method of the GRPC communication protocol and the interface address to the server, wherein the interface address is used to indicate the communication interface with the server when communicating based on the GRPC communication protocol.

[0122] In one possible implementation, the second sending module 420 is used to serialize the parameters and interface address required by the calling method of the GRPC communication protocol to obtain serialized parameters, and send the serialized parameters to the server.

[0123] The parsing module 430 is used to deserialize the return value to obtain the return data structure information of the calling method of the GRPC communication protocol.

[0124] In one possible implementation, the apparatus for communicating based on the GRPC communication protocol may further include: a construction module for acquiring a data stream identifier; and constructing a sequence number based on the data stream identifier, wherein the sequence number is used to record the position order of the data stream communicating with the server.

[0125] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the communication method based on the GPRC communication protocol described in the above method embodiments.

[0126] The computer program product of the method for communication based on the GPPC communication protocol provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the steps of the method for communication based on the GPPC communication protocol described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0127] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0128] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0129] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0130] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0131] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for communication based on the gRPC communication protocol, characterized in that, include: After establishing a connection with the server in the kernel layer, a communication data request is sent to the server. Receive the encryption key sent by the server, the encryption key being used to encrypt data during the communication process; Send the parameters required for the gRPC communication protocol invocation method to the server, including: Using the encryption key, the parameters required for calling the gRPC communication protocol are encrypted to obtain encrypted parameters; the encrypted parameters are sent to the server, wherein the parameters are used to limit the parameters passed by the calling method when communicating with the server based on the gRPC communication protocol; The server receives a return value based on the called method, parses the return value, and obtains the return data structure information of the called method of the GRPC communication protocol. The return data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the GRPC communication protocol. Specifically, when communicating with the server based on the GRPC communication protocol, the data is transmitted according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements.

2. The method according to claim 1, characterized in that, The communication data requirements include communication protocol requirements; The request to send communication data to the server includes: A phantom data packet that satisfies the requirements of the communication protocol is constructed and sent to the server. The phantom data packet is used to indicate the communication protocol used.

3. The method according to claim 1, characterized in that, The communication data requirements include frame size requirements; The request to send communication data to the server includes: A frame setting packet containing the frame size requirement is constructed and sent to the server. The frame setting packet is used to indicate the frame size and frame window size of the data transmitted during communication based on the gRPC communication protocol.

4. The method according to claim 1, characterized in that, The communication data requirements include the data stream size; The request to send communication data to the server includes: An update window packet containing the data stream size is constructed and sent to the server so that the server can update the data stream size of the current connection based on the update window packet.

5. The method according to claim 1, characterized in that, The return value is a closed-state return value; The parsing of the return value includes: The encrypted return value is decrypted using the encryption key to obtain the return data structure information of the calling method of the GRPC communication protocol.

6. The method according to any one of claims 1-5, characterized in that, Sending the parameters required for the gRPC communication protocol invocation method to the server includes: The parameters and interface address required for calling the gRPC communication protocol are sent to the server, wherein the interface address is used to indicate the communication interface with the server when communicating based on the gRPC communication protocol.

7. The method according to claim 6, characterized in that, Sending the parameters and interface address required for the GPRC communication protocol invocation method to the server includes: The parameters and interface address required for calling the gRPC communication protocol are serialized to obtain serialized parameters, and the serialized parameters are sent to the server. The step of receiving the return value based on the calling method sent by the server and parsing the return value to obtain the return data structure information of the calling method of the GPRC communication protocol includes: deserializing the return value to obtain the return data structure information of the calling method of the GPRC communication protocol.

8. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain the data stream identifier; A sequential sequence is constructed based on the data stream identifier, wherein the sequential sequence is used to record the position order of the data stream communicating with the server.

9. A device for communication based on the gRPC communication protocol, characterized in that, include: The first sending module is used to send communication data requests to the server after establishing a connection with the server in the kernel layer; The second sending module is used to send the parameters required for the calling method of the GRPC communication protocol to the server, wherein the parameters are used to limit the parameters passed by the calling method when communicating with the server based on the GRPC communication protocol; The parsing module is used to receive the return value based on the calling method from the server, parse the return value to obtain the return data structure information of the calling method of the GPRC communication protocol, wherein the return data structure information is used to indicate the data structure standard received from the server when communicating with the server based on the GPRC communication protocol; wherein, when communicating with the server based on the GPRC communication protocol, the data is configured to be transmitted according to the parameters passed by the calling method, and the format of the transmitted data is set according to the communication data requirements; A receiving module is used to receive an encryption key sent by the server, the encryption key being used to encrypt data during communication. The second sending module is further configured to use the encryption key to encrypt the parameters required for the calling method of the GRPC communication protocol to obtain encrypted parameters; and send the encrypted parameters to the server.

10. An electronic device, characterized in that, include: The processor and memory, wherein the memory stores machine-readable instructions executable by the processor, wherein when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • GRPC service dynamic calling method and system

    CN111930541A

  • Attack prevention method and device, equipment and storage medium

    CN114491517A