Communication interaction method and device, electronic equipment, storage medium and product
By pre-registering the websocket-type interface services in the gateway, dynamically creating the websocket-type interface, and establishing a connection with the server, the problem that the http server does not support the websocket-type interface is solved, streaming communication between the client and the server is realized, and the timeliness of communication is improved.
Patent Information
- Application Number
- CN202411592481.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, the http server does not support dynamic registration and call of webscoket type interfaces, resulting in the inability of streaming communication between the client and the server, affecting the timeliness of communication.
By pre-registering the service of the websocket type interface in the gateway, dynamically create the websocket type interface, and directly establish a connection with the services corresponding to the pre-registered target interface based on the request path of the target interface carried in the access request sent by the client, realizing streaming communication between the client and the server.
The streaming communication between the client and the server is realized, which improves the timeliness of communication and avoids the process of decoding each transmission of messages.
Smart Images

Figure CN119603367A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a communication interaction method, device, electronic device, storage medium and product. Background Art
[0002] In the existing moleculer system, the created http server does not support the websocket type interface, that is, the created http server does not support the dynamic registration and calling of the websocket type interface. In order to access the websocket type interface in the http server, the existing technology usually creates a gateway, and uses the gateway to create a fixed interface of the websocket type. The caller who wants to access the websocket type interface indicates the target interface in the message to be sent. The gateway can decode and identify the message, and then establish a connection with the decoded and identified target interface to send the message.
[0003] However, in the prior art, after receiving the message, the gateway needs to decode the message to identify the target interface, then establish a connection with the target interface and send the message, which makes it impossible for the client and the server to perform streaming communication, thus affecting the timeliness of the communication. Summary of the invention
[0004] Based on the above requirements, the present application proposes a communication interaction method, device, electronic device, storage medium and product, which can realize streaming communication between the client and the server and improve the timeliness of communication.
[0005] To achieve the above objectives, this application proposes the following technical solutions:
[0006] According to a first aspect of an embodiment of the present application, a communication interaction method is provided, including:
[0007] Identify the access request sent by the client and determine the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request;
[0008] If the request type of the access request indicates accessing a websocket type interface, querying the service information of the target interface according to the request path of the target interface;
[0009] Based on the service information of the target interface, a connection is established with the target service corresponding to the target interface to realize the communication interaction between the client and the target interface; wherein the service corresponding to the interface includes the service corresponding to the pre-registered websocket type interface.
[0010] Optionally, the registration process of the service corresponding to the interface includes:
[0011] Using a pre-built proxy service to update and monitor the configuration information of the proxy service when it is installed, record the updated configuration information and detect the running status of the proxy service; wherein the proxy service is a background service with a websocket type interface;
[0012] When the running state of the proxied service indicates running, a service unit of the websocket type interface in the proxied service is created by using the pre-built proxy service, and the service unit corresponding to the websocket type interface in the proxied service is registered in the gateway.
[0013] Optionally, querying service information of the target interface according to the request path of the target interface includes:
[0014] According to the request path of the target interface, query whether there is a service unit corresponding to the target interface in a pre-built service list; wherein the service list includes service units that have been registered in the gateway;
[0015] If the service unit corresponding to the target interface exists in the service list, the service information of the target interface is obtained from the configuration information of the proxy service record.
[0016] Optionally, the communication interaction method further includes:
[0017] If the service unit corresponding to the target interface does not exist in the service list, an error message is output; the error message indicates that the target service corresponding to the target interface is not registered in the gateway.
[0018] Optionally, the communication interaction method further includes:
[0019] If the request type of the access request indicates accessing a RESTful type interface or accessing a GraphQL type interface, a communication interaction is established between the client and the target interface.
[0020] Optionally, identifying the access request sent by the client and determining the request type of the access request includes:
[0021] Identify the access request sent by the client and determine whether the access request triggers an upgrade event;
[0022] If the access request triggers an upgrade event, it is determined that the request type of the access request indicates access to a websocket type interface.
[0023] According to a second aspect of an embodiment of the present application, a communication interaction device is provided, including:
[0024] A request identification module, used to identify the access request sent by the client and determine the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request;
[0025] A service query module, configured to query service information of the target interface according to the request path of the target interface if the request type of the access request indicates access to a websocket type interface;
[0026] A connection establishment module is used to establish a connection with a target service corresponding to the target interface based on the service information of the target interface to achieve communication interaction between the client and the target interface; wherein the service corresponding to the interface includes a service corresponding to a pre-registered websocket type interface.
[0027] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including: a memory and a processor;
[0028] The memory is connected to the processor and is used to store programs;
[0029] The processor is used to implement the above communication interaction method by running the program in the memory.
[0030] According to a fourth aspect of an embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned communication interaction method is implemented.
[0031] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer program instructions, which, when executed by a processor, enable the processor to implement the above-mentioned communication interaction method.
[0032] The communication interaction method proposed in the present application identifies the access request sent by the client and determines the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request; if the request type of the access request indicates accessing a websocket type interface, then according to the request path of the target interface, the service information of the target interface is queried; based on the service information of the target interface, a connection is established with the target service corresponding to the target interface to realize the communication interaction between the client and the target interface; wherein the service corresponding to the interface includes the service corresponding to the pre-registered websocket type interface. By adopting the technical solution of the present application, the service corresponding to the websocket type interface can be pre-registered in the gateway, and the websocket type interface can be dynamically created by the gateway. The gateway directly establishes a connection with the service corresponding to the pre-registered target interface according to the request path of the target interface carried in the access request sent by the client, and then directly uses the connected pipeline for communication interaction, without the need to decode the message before transmitting it each time, so that streaming communication between the client and the server can be realized, and the timeliness of communication can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0034] Figure 1 A flow chart of a communication interaction method provided in an embodiment of the present application;
[0035] Figure 2 A schematic diagram of the processing flow of the service corresponding to the registration interface provided in the embodiment of the present application;
[0036] Figure 3 A schematic diagram of a process flow for querying service information of a target interface provided in an embodiment of the present application;
[0037] Figure 4 A flowchart of another communication interaction method provided in an embodiment of the present application;
[0038] Figure 5 A schematic diagram of the structure of a communication interaction device provided in an embodiment of the present application;
[0039] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The technical solution of the embodiment of the present application is applicable to the application scenario of communication interaction, and is specifically used in the application scenario of communication interaction between the webscoket type interface of the client and the server. The technical solution of the embodiment of the present application can realize streaming communication between the client and the server, and improve the timeliness of communication.
[0041] In the existing moleculer system, users can register the interfaces they need into the system through its decentralized service discovery mechanism. However, the HTTP server created in the existing moleculer system only supports the definition of two types of interfaces: RESTful and GraphQL. It does not support webscoket type interfaces, and does not support dynamic registration and calling of webscoket type interfaces.
[0042] In order to enable the client to access the websocket type interface through the http server created in the existing moleculer system, the existing technology usually creates a gateway and then uses the gateway to create a fixed interface of the websocket type. If the client wants to access the websocket type interface and communicate with the server through the websocket type interface, the client needs to indicate the interface information it wants to access in the information sent, such as the interface type, interface address, etc. After receiving the information sent by the client, the gateway needs to decode and identify the information, identify the interface information that the client wants to access, and establish a connection with the corresponding interface based on the interface information, and forward the message sent by the client to the corresponding interface.
[0043] However, in the prior art, the gateway needs to decode and identify the message sent by the client each time it receives it in order to identify the target interface, establish a connection with the target interface and forward the message, which results in a long delay when the message sent by the client reaches the server. In addition, the gateway needs to decode the message each time the client sends it, and streaming communication between the client and the server cannot be achieved, affecting the timeliness of communication.
[0044] Based on this, the present application proposes a communication interaction method. This technical solution can pre-register the service corresponding to the websocket type interface in the gateway, and realize the dynamic creation of the websocket type interface by using the gateway. The gateway directly establishes a connection with the service corresponding to the pre-registered target interface according to the request path of the target interface carried in the access request sent by the client, and then directly uses the connected pipeline for communication interaction, thereby solving the problem that the existing technology cannot realize streaming communication between the client and the server, and the timeliness of communication is low.
[0045] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0046] Exemplary Methods
[0047] See also Figure 1 As shown, the embodiment of the present application proposes a communication interaction method. The method includes:
[0048] S101: Identify an access request sent by a client and determine the request type of the access request.
[0049] In this embodiment, before the client communicates with the server, the client needs to send an access request according to the interface it wants to access when accessing the server, wherein the access request carries the request path of the target interface accessed by the client. The client sends the access request to the gateway, and after receiving the access request, the gateway needs to identify the access request, identify the request type to which the access request belongs, and then determine the request type of the access request according to the access type of the access request.
[0050] Specifically, this embodiment identifies the access request and identifies the access type to which the access request belongs. Among them, the access types include: upgrade request access, restful request access, graphql request access, etc. If the access request includes an upgrade request header, it means that the access type of the access request is upgrade request access. Restful request access is a request defined in XML or JSON format, and graphql request access is a request written in GraphQL language. Through the formats corresponding to the above various access types, the access type to which the access request belongs can be identified. If it is identified that the access type to which the access request belongs is upgrade request access, it is determined that the request type of the access request represents access to a websocket type interface; if it is identified that the access type to which the access request belongs is restful request access, it is determined that the request type of the access request represents access to a restful type interface; if it is identified that the access type to which the access request belongs is graphql request access, it is determined that the request type of the access request represents access to a graphql type interface.
[0051] As an optional implementation, identifying the access request sent by the client and determining the request type of the access request specifically includes the following steps:
[0052] First, identify the access request sent by the client to determine whether the access request triggers an upgrade event.
[0053] When identifying an access request sent by a client, this embodiment needs to determine whether the access request triggers an upgrade event. The upgrade event only has an upgrade request. That is to say, if it is determined that the access request triggers an upgrade event, it means that the access type of the access request sent by the client is upgrade request access. If it is determined that the access request sent by the client does not trigger an upgrade event, it means that the access type of the access request sent by the client is restful request access or graphql request access.
[0054] Second, if the access request triggers an upgrade event, it is determined that the request type of the access request represents access to a websocket type interface.
[0055] Since only the communication of the websocket protocol will trigger the upgrade event, that is, only when the client accesses the websocket type interface, the access request will trigger the upgrade event. Therefore, if it is determined that the access request sent by the client triggers the upgrade event, it is determined that the request type of the access request indicates access to the websocket type interface. If it is determined that the access request sent by the client does not trigger the upgrade event, it is determined that the request type of the access request indicates access to the restful type interface or access to the graphql type interface. When the access request does not trigger the upgrade event, it is still necessary to determine whether the request type of the access request indicates access to the restful type interface or access to the graphql type interface, or to analyze whether the access request belongs to the restful request access or the graphql request access as described above.
[0056] S102: If the request type of the access request indicates accessing a websocket type interface, query service information of the target interface according to the request path of the target interface.
[0057] In this embodiment, if it is determined through the above steps that the request type of the access request indicates access to a websocket type interface, it is necessary to query the service information of the target interface based on the request path of the target interface to be accessed carried in the access request (that is, the request path of the websocket type interface that the client wants to access).
[0058] Specifically, in this embodiment, the gateway needs to analyze the target interface corresponding to the request path according to the request path carried in the access request. The gateway can dynamically create a websocket type interface in advance, that is, the gateway includes the service corresponding to the websocket type interface pre-registered with the proxy service. After the gateway analyzes the target interface corresponding to the request path carried in the access request, it will query the proxy service for the service information of the target interface when the proxy service registers the service corresponding to the target interface to the gateway. Among them, the service information of the target interface includes: service port, interface type, IP address and other information.
[0059] S103: Establish a connection with a target service corresponding to the target interface based on the service information of the target interface to achieve communication interaction between the client and the target interface.
[0060] After querying the service information of the target interface through the above steps, the gateway needs to determine the target service corresponding to the target interface according to the service information of the target interface, and then establish a connection with the target service corresponding to the target interface, so that the client can communicate with the target interface of the server through the target service corresponding to the target interface registered in the gateway, so as to stream information between the client and the server. In this embodiment, the service corresponding to the interface includes the service corresponding to the pre-registered websocket type interface.
[0061] From the above introduction, it can be seen that the communication interaction method proposed in the embodiment of the present application identifies the access request sent by the client and determines the request type of the access request; wherein, the access request carries the request path of the target interface accessed by the access request; if the request type of the access request indicates access to a websocket type interface, then according to the request path of the target interface, the service information of the target interface is queried; based on the service information of the target interface, a connection is established with the target service corresponding to the target interface to realize the communication interaction between the client and the target interface; wherein, the service corresponding to the interface includes the service corresponding to the pre-registered websocket type interface. By adopting the technical solution of this embodiment, the service corresponding to the websocket type interface can be pre-registered in the gateway, and the websocket type interface can be dynamically created by the gateway. The gateway directly establishes a connection with the service corresponding to the pre-registered target interface according to the request path of the target interface carried in the access request sent by the client, and then directly uses the connected pipeline for communication interaction, without decoding the message before transmitting it each time, so as to realize streaming communication between the client and the server and improve the timeliness of communication.
[0062] As an optional implementation, see Figure 2As shown, in another embodiment of the present application, a registration process of a service corresponding to an interface is disclosed, which specifically includes the following steps:
[0063] S201. Use the pre-built proxy service to update and monitor the configuration information of the proxy service during installation, record the updated configuration information and detect the running status of the proxy service.
[0064] In this embodiment, a proxy service is pre-built, and a background service with a websocket type interface is used as a proxied service. When a background service with a websocket type interface is added, or a background service adds a websocket type interface, the background service needs to be installed as a proxied service. When installing a proxied service, the configuration information will be incrementally updated, where the configuration information includes information such as the service port, IP address, interface list, and interface type of the proxied service.
[0065] The pre-built proxy service monitors and reads the configuration information. When the configuration information is updated, the proxy service records the updated configuration information according to the updated configuration information. At the same time, the proxy service also needs to monitor the running status of the proxy service in real time to determine whether the proxy service is running.
[0066] S202: When the running state of the proxied service indicates running, using the pre-built proxy service, create a service unit of the websocket type interface in the proxied service, and register the service unit corresponding to the websocket type interface in the proxied service in the gateway.
[0067] When the proxy service detects that the proxied service is running, the proxy service creates corresponding service units for the websocket type interface in the running proxied service, that is, the proxy service creates service units corresponding to each websocket type interface in the proxied service. After the proxy service constructs the service units corresponding to each websocket type interface, it also needs to register each service unit it created with the gateway as the service corresponding to each websocket type interface.
[0068] As an optional implementation, see Figure 3 As shown, in another embodiment of the present application, in step S102, according to the request path of the target interface, the service information of the target interface is queried, which specifically includes the following steps:
[0069] S301. According to the request path of the target interface, query whether there is a service unit corresponding to the target interface in the pre-built service list; if so, execute step S302; if not, execute step S303.
[0070] In this embodiment, the proxy service registers all service units corresponding to the websocket type interface in the proxy service into the gateway. Therefore, a service list is pre-constructed in the gateway, and the service list stores the service units corresponding to each websocket type interface registered in the gateway. If it is determined that the request type of the access request sent by the client indicates access to a websocket type interface, the gateway needs to determine the target interface corresponding to the request path according to the request path carried in the access request, and query whether there is a service unit corresponding to the target interface in the pre-constructed service list. If the gateway finds that there is a service unit corresponding to the target interface in the service list, it means that the proxy service has registered the service unit corresponding to the target interface in the gateway, and step S302 is executed at this time; if the gateway finds that there is no service unit corresponding to the target interface in the service list, it means that the proxy service has not registered the service unit corresponding to the target interface in the gateway, and step S303 is executed at this time.
[0071] S302: Obtain service information of the target interface from the configuration information recorded by the proxy service.
[0072] In this embodiment, if the gateway finds that there is a service unit corresponding to the target interface in the service list, it means that the proxy service has registered the service unit corresponding to the target interface in the gateway, which means that the proxy service has recorded the configuration information of the target interface. At this time, the gateway needs to query the configuration information corresponding to the target interface from all the configuration information recorded by the proxy service as the service information of the target interface. That is, the service information of the target interface includes: the service port, IP address and interface type of the proxied service to which the target interface belongs.
[0073] S303: Output error information.
[0074] In this embodiment, if the gateway queries and finds that the service unit corresponding to the target interface does not exist in the service list, it means that the proxy service has not registered the service unit corresponding to the target interface in the gateway. At this time, the client cannot access the target interface through the gateway. Therefore, it is necessary to output an error message indicating that the target service corresponding to the target interface is not registered in the gateway, so that the client understands the reason why the target interface cannot be accessed.
[0075] As an optional implementation, see Figure 4 As shown, in another embodiment of the present application, the communication interaction method further includes the following steps:
[0076] S401. If the request type of the access request indicates accessing a RESTful type interface or accessing a GraphQL type interface, a communication interaction is established between the client and the target interface.
[0077] In the http server, it supports the definition of restful type interface and graphql type interface, so it is possible to directly establish a connection between the client and the restful type interface and graphql type interface in the server, and realize the communication interaction between the client and the restful type interface and graphql type interface in the server. Therefore, if it is determined that the request type of the access request sent by the client indicates access to the restful type interface or the graphql type interface, then directly establish a connection between the client and the target interface, and realize the communication interaction between the client and the target interface.
[0078] This embodiment can not only realize the communication interaction between the restful type interface and the graphql type interface in the client and the server, but also realize the communication interaction between the websocket type interface in the client and the server, and realize that the server not only supports the restful type interface and the graphql type interface, but also dynamically creates the service of the websocket type interface through the gateway, and realizes the server's support for the websocket type interface, so that the server supports the restful type interface, the graphql type interface and the websocket type interface at the same time.
[0079] Exemplary Devices
[0080] Accordingly, the present application also provides a communication interaction device, see Figure 5 As shown, the device comprises:
[0081] The request identification module 100 is used to identify the access request sent by the client and determine the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request;
[0082] The service query module 110 is used to query the service information of the target interface according to the request path of the target interface if the request type of the access request indicates accessing a websocket type interface;
[0083] The connection establishment module 120 is used to establish a connection with a target service corresponding to the target interface based on the service information of the target interface to realize communication interaction between the client and the target interface; wherein the service corresponding to the interface includes a service corresponding to a pre-registered websocket type interface.
[0084] From the above introduction, it can be seen that the communication interaction device proposed in the embodiment of the present application can pre-register the service corresponding to the websocket type interface in the gateway, and realize the dynamic creation of the websocket type interface by using the gateway. The gateway directly establishes a connection with the service corresponding to the pre-registered target interface according to the request path of the target interface carried in the access request sent by the client, and then directly uses the connected pipeline for communication interaction. There is no need to decode the message before transmitting it each time, which can realize streaming communication between the client and the server and improve the timeliness of communication.
[0085] As an optional implementation, another embodiment of the present application discloses that the communication interaction device further includes: a configuration information recording module and a service creation module.
[0086] The configuration information recording module is used to update and monitor the configuration information of the proxy service when it is installed by using the pre-built proxy service, record the updated configuration information and detect the running status of the proxy service; wherein the proxy service is a background service with a websocket type interface;
[0087] The service creation module is used to create a service unit of the websocket type interface in the proxied service by using the pre-built proxy service when the running state of the proxied service indicates running, and register the service unit corresponding to the websocket type interface in the proxied service with the gateway.
[0088] As an optional implementation, another embodiment of the present application discloses that the service query module 110 includes: a query unit and an acquisition unit.
[0089] A query unit, used to query whether there is a service unit corresponding to the target interface in a pre-built service list according to the request path of the target interface; wherein the service list includes service units that have been registered in the gateway;
[0090] The acquisition unit is used to acquire the service information of the target interface from the configuration information recorded by the proxy service if there is a service unit corresponding to the target interface in the service list.
[0091] As an optional implementation, another embodiment of the present application discloses that the service query module 110 further includes: an output unit.
[0092] The output unit is used to output an error message if the service unit corresponding to the target interface does not exist in the service list; the error message indicates that the target service corresponding to the target interface is not registered in the gateway.
[0093] As an optional implementation, another embodiment of the present application discloses that the communication interaction device further includes: a communication establishment module.
[0094] The communication establishment module is used to establish communication interaction between the client and the target interface if the request type of the access request indicates access to a restful type interface or access to a graphql type interface.
[0095] As an optional implementation, another embodiment of the present application discloses a request identification module, which is specifically used to:
[0096] Identify the access request sent by the client and determine whether the access request triggers an upgrade event;
[0097] If the access request triggers the upgrade event, it is determined that the request type of the access request represents access to a websocket type interface.
[0098] The communication interaction device provided in this embodiment belongs to the same application concept as the communication interaction method provided in the above embodiments of this application, can execute the communication interaction method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the communication interaction method. For technical details not fully described in this embodiment, please refer to the specific processing content of the communication interaction method provided in the above embodiments of this application, which will not be repeated here.
[0099] Exemplary Electronic Devices
[0100] Another embodiment of the present application also provides an electronic device, see Figure 6 As shown, the device includes:
[0101] Memory 200 and processor 210;
[0102] The memory 200 is connected to the processor 210 and is used to store programs;
[0103] The processor 210 is used to implement the communication interaction method disclosed in any of the above embodiments by running the program stored in the memory 200.
[0104] Specifically, the electronic device may further include: a bus, a communication interface 220 , an input device 230 and an output device 240 .
[0105] The processor 210, the memory 200, the communication interface 220, the input device 230 and the output device 240 are connected to each other via a bus.
[0106] A bus may include a pathway that transfers information between components of a computer system.
[0107] The processor 210 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. 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, discrete hardware components.
[0108] The processor 210 may include a main processor, and may also include a baseband chip, a modem, and the like.
[0109] The memory 200 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.
[0110] The input device 230 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.
[0111] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0112] The communication interface 220 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0113] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement each step of any communication interaction method provided in the above embodiments of the present application.
[0114] Exemplary computer program products and storage media
[0115] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the communication interaction method according to various embodiments of the present application described in the above-mentioned "Exemplary Method" section of this specification.
[0116] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0117] In addition, an embodiment of the present application may also be a storage medium on which a computer program is stored, and the computer program is executed by a processor to execute the steps of the communication interaction method according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.
[0118] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0119] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0120] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0121] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.
[0122] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0123] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0124] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0125] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0126] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0127] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used 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. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0128] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A communication interaction method, characterized in that: include: Identify the access request sent by the client and determine the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request; If the request type of the access request indicates accessing a websocket type interface, querying the service information of the target interface according to the request path of the target interface; Based on the service information of the target interface, a connection is established with the target service corresponding to the target interface to realize the communication interaction between the client and the target interface; wherein the service corresponding to the interface includes the service corresponding to the pre-registered websocket type interface.
2. The method according to claim 1, characterized in that: The registration process of the service corresponding to the interface includes: Using a pre-built proxy service to update and monitor the configuration information of the proxy service when it is installed, record the updated configuration information and detect the running status of the proxy service; wherein the proxy service is a background service with a websocket type interface; When the running state of the proxied service indicates running, a service unit of the websocket type interface in the proxied service is created by using the pre-built proxy service, and the service unit corresponding to the websocket type interface in the proxied service is registered in the gateway.
3. The method according to claim 1, characterized in that Querying service information of the target interface according to the request path of the target interface includes: According to the request path of the target interface, query whether there is a service unit corresponding to the target interface in a pre-built service list; wherein the service list includes service units that have been registered in the gateway; If the service unit corresponding to the target interface exists in the service list, the service information of the target interface is obtained from the configuration information of the proxy service record.
4. The method according to claim 3, characterized in that Also includes: If the service unit corresponding to the target interface does not exist in the service list, an error message is output; The error message indicates that the target service corresponding to the target interface is not registered in the gateway.
5. The method according to claim 1, characterized in that Also includes: If the request type of the access request indicates accessing a RESTful type interface or accessing a GraphQL type interface, a communication interaction is established between the client and the target interface.
6. The method according to claim 1, characterized in that Identifying the access request sent by the client and determining the request type of the access request includes: Identify the access request sent by the client and determine whether the access request triggers an upgrade event; If the access request triggers an upgrade event, it is determined that the request type of the access request indicates access to a websocket type interface.
7. A communication interaction device, characterized in that: include: A request identification module, used to identify the access request sent by the client and determine the request type of the access request; wherein the access request carries the request path of the target interface accessed by the access request; A service query module, configured to query service information of the target interface according to the request path of the target interface if the request type of the access request indicates access to a websocket type interface; A connection establishment module is used to establish a connection with a target service corresponding to the target interface based on the service information of the target interface to achieve communication interaction between the client and the target interface; wherein the service corresponding to the interface includes a service corresponding to a pre-registered websocket type interface.
8. An electronic device, characterized in that: include: Memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the communication interaction method as described in any one of claims 1 to 6 by running the program in the memory.
9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the communication interaction method according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The method comprises computer program instructions, which, when executed by a processor, enable the processor to implement the communication interaction method as claimed in any one of claims 1 to 6.