[go: up one dir, main page]

CN115103005B - Request response method, device, electronic device and storage medium - Google Patents

Request response method, device, electronic device and storage medium Download PDF

Info

Publication number
CN115103005B
CN115103005B CN202210673000.2A CN202210673000A CN115103005B CN 115103005 B CN115103005 B CN 115103005B CN 202210673000 A CN202210673000 A CN 202210673000A CN 115103005 B CN115103005 B CN 115103005B
Authority
CN
China
Prior art keywords
client
server
response
transmission channel
message transmission
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210673000.2A
Other languages
Chinese (zh)
Other versions
CN115103005A (en
Inventor
梁威
岳晓敏
韩金魁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Qianshi Technology Co Ltd
Original Assignee
Beijing Jingdong Qianshi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Qianshi Technology Co Ltd filed Critical Beijing Jingdong Qianshi Technology Co Ltd
Priority to CN202210673000.2A priority Critical patent/CN115103005B/en
Publication of CN115103005A publication Critical patent/CN115103005A/en
Application granted granted Critical
Publication of CN115103005B publication Critical patent/CN115103005B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer And Data Communications (AREA)
  • Information Transfer Between Computers (AREA)
  • Communication Control (AREA)

Abstract

The present disclosure provides a request response method, a request response device, an electronic device, and a storage medium, where the method includes: sending a service request to a server; monitoring a service end in response to a service request; in response to monitoring that the server responds to the timeout, disconnecting the synchronous message transmission channel between the server and the client, and creating an asynchronous message transmission channel for reconnecting the client and the server; and receiving a response message for the service request from the service terminal through the asynchronous message transmission channel.

Description

请求响应方法、装置、电子设备及存储介质Request response method, device, electronic device and storage medium

技术领域Technical Field

本公开涉及计算机技术领域,更具体地,涉及一种请求响应方法、装置、电子设备、计算机可读存储介质以及计算机程序产品。The present disclosure relates to the field of computer technology, and more specifically, to a request response method, device, electronic device, computer-readable storage medium, and computer program product.

背景技术Background Art

在客户端与服务端进行交互的过程中,客户端一般设置有超时时长,超时时长可以是研发人员根据经验设置的。实际应用中,由于使用环境差异较大,研发人员难以准确预估超时时间,因此经常发生客户端超时的事件。发生超时事件时,客户端会向用户展示提示信息来告知用户出现异常,然后用户可以根据实际需求重复操作,再次利用客户端发送服务请求,以便获得所需的信息,上述过程会影响用户体验。In the process of interaction between the client and the server, the client is generally set with a timeout period, which can be set by the R&D personnel based on experience. In actual applications, due to the large differences in usage environments, it is difficult for R&D personnel to accurately estimate the timeout period, so client timeout events often occur. When a timeout event occurs, the client will display a prompt message to the user to inform the user of the abnormality. The user can then repeat the operation according to actual needs and use the client to send a service request again to obtain the required information. The above process will affect the user experience.

发明内容Summary of the invention

本公开提供了一种请求响应方法、装置、电子设备、计算机可读存储介质以及计算机程序产品,能够在客户端超时而中断连接后,将响应消息通过异步消息传输通道发送至客户端。The present disclosure provides a request response method, device, electronic device, computer-readable storage medium and computer program product, which can send a response message to a client through an asynchronous message transmission channel after the client times out and disconnects.

本公开的一个方面提供了一种请求响应方法,包括:向服务端发送服务请求;对所述服务端响应所述服务请求进行监测;响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道;以及通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息。One aspect of the present disclosure provides a request response method, comprising: sending a service request to a server; monitoring the server's response to the service request; disconnecting a synchronous message transmission channel between the server and the client in response to monitoring that the server's response has timed out, creating an asynchronous message transmission channel for reconnecting the client and the server; and receiving a response message to the service request from the server through the asynchronous message transmission channel.

根据本公开另一实施例,所述响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道包括:响应于监测到所述同步消息传输通道已断开,创建所述客户端的套接字;利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应;响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。According to another embodiment of the present disclosure, in response to detecting that the server response has timed out and disconnecting the synchronous message transmission channel between the server and the client, creating an asynchronous message transmission channel for reconnecting the client and the server includes: in response to detecting that the synchronous message transmission channel has been disconnected, creating a socket of the client; using the socket of the client to send a connection request to the socket of the server, so that the socket of the server processes the connection request and obtains a connection response; in response to receiving a connection response from the socket of the server, creating the asynchronous message transmission channel.

根据本公开另一实施例,还包括:在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,所述连接池中存储有所述客户端向所述服务端发送的服务请求;以及在所述连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建所述异步消息传输通道。According to another embodiment of the present disclosure, it also includes: before creating an asynchronous message transmission channel for reconnecting the client and the server, obtaining the running status information of the connection pool, wherein the connection pool stores the service request sent by the client to the server; and triggering a creation operation to create the asynchronous message transmission channel when the running status information of the connection pool meets a preset running condition.

根据本公开另一实施例,所述预设运行条件包括所述连接池中存储的请求数量大于或等于第一预设阈值;以及/或者所述连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。According to another embodiment of the present disclosure, the preset operating conditions include that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the ratio of the number of requests stored in the connection pool to the maximum number of requests is greater than or equal to a second preset threshold.

根据本公开另一实施例,所述对所述服务端响应所述服务请求进行监测包括:利用超时处理函数对所述客户端等待所述服务端响应所述服务请求消耗的时长进行监测。According to another embodiment of the present disclosure, the monitoring of the server's response to the service request includes: using a timeout processing function to monitor the time the client spends waiting for the server to respond to the service request.

根据本公开另一实施例,还包括:在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之后,输出用于提示等待所述响应信息的提示信息。According to another embodiment of the present disclosure, it also includes: after creating an asynchronous message transmission channel for reconnecting the client and the server, outputting prompt information for prompting to wait for the response information.

本公开的另一个方面提供了一种请求响应方法,包括:响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息;响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息;以及其中,所述异步消息传输通道是在所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。Another aspect of the present disclosure provides a request response method, comprising: in response to receiving a service request from a client, processing the service request to obtain a response message; in response to monitoring that a synchronous message transmission channel between the client and the server is disconnected, sending the response message to the client through an asynchronous message transmission channel; and wherein the asynchronous message transmission channel is created when the synchronous message transmission channel is disconnected due to a response timeout on the server, and the asynchronous message transmission channel is used to reconnect the client and the server.

根据本公开另一实施例,还包括:在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字;在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应;向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道;其中,所述客户端的套接字是所述客户端在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, it also includes: before sending the response message to the client through the asynchronous message transmission channel, creating the socket of the server; when the socket of the server detects a connection request from the socket of the client, processing the connection request to obtain a connection response; sending the connection response to the socket of the client to create the asynchronous message transmission channel; wherein the socket of the client is created when the client detects that the response of the server has timed out and disconnects the synchronous message transmission channel.

根据本公开另一实施例,所述响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息包括:响应于监测到指示所述同步消息传输通道断开的中断消息,根据所述中断消息,从多个候选响应消息中确定针对所述服务请求的所述响应消息;以及通过所述异步消息传输通道向所述客户端发送所述响应消息。According to another embodiment of the present disclosure, in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected, sending the response message to the client through the asynchronous message transmission channel includes: in response to monitoring an interrupt message indicating that the synchronous message transmission channel is disconnected, determining the response message for the service request from multiple candidate response messages based on the interrupt message; and sending the response message to the client through the asynchronous message transmission channel.

本公开的另一个方面提供了一种请求响应装置,包括第一发送模块、监测模块、第一创建模块以及接收模块。第一发送模块用于向服务端发送服务请求。监测模块用于对所述服务端响应所述服务请求进行监测。第一创建模块用于响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道。接收模块用于通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息。Another aspect of the present disclosure provides a request response device, including a first sending module, a monitoring module, a first creation module and a receiving module. The first sending module is used to send a service request to a server. The monitoring module is used to monitor the response of the server to the service request. The first creation module is used to disconnect the synchronous message transmission channel between the server and the client in response to monitoring that the server response has timed out, and create an asynchronous message transmission channel for reconnecting the client and the server. The receiving module is used to receive a response message to the service request from the server through the asynchronous message transmission channel.

根据本公开另一实施例,所述第一创建模块包括第一创建子模块、第一发送子模块和第二创建子模块。第一创建子模块用于响应于监测到所述同步消息传输通道已断开,创建所述客户端的套接字。第一发送子模块用于利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应。第二创建子模块用于响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。According to another embodiment of the present disclosure, the first creation module includes a first creation submodule, a first sending submodule and a second creation submodule. The first creation submodule is used to create the socket of the client in response to monitoring that the synchronous message transmission channel has been disconnected. The first sending submodule is used to use the socket of the client to send a connection request to the socket of the server, so that the socket of the server processes the connection request and obtains a connection response. The second creation submodule is used to create the asynchronous message transmission channel in response to receiving a connection response from the socket of the server.

根据本公开另一实施例,上述请求响应装置还包括获取模块和触发模块。获取模块用于在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,所述连接池中存储有所述客户端向所述服务端发送的服务请求。触发模块用于在所述连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建所述异步消息传输通道。According to another embodiment of the present disclosure, the request response device further includes an acquisition module and a trigger module. The acquisition module is used to acquire the operation status information of the connection pool before creating an asynchronous message transmission channel for reconnecting the client and the server, wherein the connection pool stores the service request sent by the client to the server. The trigger module is used to trigger a creation operation to create the asynchronous message transmission channel when the operation status information of the connection pool meets a preset operation condition.

根据本公开另一实施例,所述预设运行条件包括所述连接池中存储的请求数量大于或等于第一预设阈值;以及/或者所述连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。According to another embodiment of the present disclosure, the preset operating conditions include that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the ratio of the number of requests stored in the connection pool to the maximum number of requests is greater than or equal to a second preset threshold.

根据本公开另一实施例,所述监测模块包括监测子模块,用于利用超时处理函数对所述客户端等待所述服务端响应所述服务请求消耗的时长进行监测。According to another embodiment of the present disclosure, the monitoring module includes a monitoring submodule for monitoring the time consumed by the client waiting for the server to respond to the service request by using a timeout processing function.

根据本公开另一实施例,上述请求响应装置还包括提示模块,用于在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之后,输出用于提示等待所述响应信息的提示信息。According to another embodiment of the present disclosure, the request response device further includes a prompt module for outputting prompt information for waiting for the response information after creating an asynchronous message transmission channel for reconnecting the client and the server.

本公开的另一个方面提供了一种请求响应装置,包括第一处理模块和第二发送模块。Another aspect of the present disclosure provides a request response device, including a first processing module and a second sending module.

第一处理模块用于响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息。The first processing module is used for processing the service request in response to receiving the service request from the client to obtain a response message.

第二发送模块用于响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息。所述异步消息传输通道是在所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。The second sending module is used for sending the response message to the client through the asynchronous message transmission channel in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected. The asynchronous message transmission channel is created when the server responds to a timeout and disconnects the synchronous message transmission channel, and the asynchronous message transmission channel is used to reconnect the client and the server.

根据本公开另一实施例,上述请求响应装置还包括第二创建模块、第二处理模块和第三发送模块。第二创建模块用于在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字。第二处理模块用于在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应。第三发送模块用于向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道。所述客户端的套接字是所述客户端在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the request response device further includes a second creation module, a second processing module and a third sending module. The second creation module is used to create the socket of the server before sending the response message to the client through the asynchronous message transmission channel. The second processing module is used to process the connection request to obtain a connection response when the socket of the server detects a connection request from the socket of the client. The third sending module is used to send the connection response to the socket of the client so as to create the asynchronous message transmission channel. The socket of the client is created when the client detects that the response of the server has timed out and disconnects the synchronous message transmission channel.

根据本公开另一实施例,所述第二发送模块包括确定子模块和第二发送子模块。确定子模块用于响应于监测到指示所述同步消息传输通道断开的中断消息,根据所述中断消息,从多个候选响应消息中确定针对所述服务请求的所述响应消息。第二发送子模块用于通过所述异步消息传输通道向所述客户端发送所述响应消息。According to another embodiment of the present disclosure, the second sending module includes a determining submodule and a second sending submodule. The determining submodule is used to determine the response message for the service request from multiple candidate response messages in response to monitoring an interrupt message indicating that the synchronous message transmission channel is disconnected, according to the interrupt message. The second sending submodule is used to send the response message to the client through the asynchronous message transmission channel.

本公开的另一方面提供了一种电子设备,包括一个或多个处理器,还包括用于存储一个或多个程序的存储器;其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现本公开实施例所述的方法。Another aspect of the present disclosure provides an electronic device, comprising one or more processors and a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in the embodiments of the present disclosure.

本公开的另一方面提供了一种计算机可读存储介质,存储有计算机可执行指令,所述指令在被执行时用于实现本公开实施例所述的方法。Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method described in the embodiments of the present disclosure when executed.

本公开的另一方面提供了一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述指令在被执行时用于实现本公开实施例所述的方法。Another aspect of the present disclosure provides a computer program product, which includes computer executable instructions. When the instructions are executed, they are used to implement the method described in the embodiments of the present disclosure.

根据本公开的实施例,在客户端和服务端之间的同步消息传输通道由于超时而断开后,可以创建异步消息传输通道,然后服务端利用异步消息传输通道将响应消息发送至客户端,从而确保客户端与服务端正常通信。此外,用户无需重复发送服务请求来获取响应消息,从而提高用户体验。According to an embodiment of the present disclosure, after the synchronous message transmission channel between the client and the server is disconnected due to timeout, an asynchronous message transmission channel can be created, and then the server uses the asynchronous message transmission channel to send a response message to the client, thereby ensuring normal communication between the client and the server. In addition, the user does not need to repeatedly send a service request to obtain a response message, thereby improving the user experience.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

通过以下参照附图对本公开实施例的描述,本公开的上述以及其他目的、特征和优点将更为清楚,在附图中:The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

图1示意性示出了可以应用本公开的请求响应方法和装置的示例性系统架构;FIG1 schematically shows an exemplary system architecture to which the request response method and apparatus of the present disclosure may be applied;

图2示意性示出了根据本公开实施例的请求响应方法的流程图;FIG2 schematically shows a flow chart of a request response method according to an embodiment of the present disclosure;

图3示意性示出了根据本公开另一实施例的请求响应方法的流程图;FIG3 schematically shows a flow chart of a request response method according to another embodiment of the present disclosure;

图4示意性示出了根据本公开实施例的请求响应装置的框图;FIG4 schematically shows a block diagram of a request response device according to an embodiment of the present disclosure;

图5示意性示出了根据本公开另一实施例的请求响应装置的框图;以及FIG5 schematically shows a block diagram of a request response device according to another embodiment of the present disclosure; and

图6示意性示出了根据本公开实施例的适于实现请求响应方法和装置的电子设备的框图。FIG6 schematically shows a block diagram of an electronic device suitable for implementing a request response method and apparatus according to an embodiment of the present disclosure.

具体实施方式DETAILED DESCRIPTION

以下,将参照附图来描述本公开的实施例。但是应该理解,这些描述只是示例性的,而并非要限制本公开的范围。在下面的详细描述中,为便于解释,阐述了许多具体的细节以提供对本公开实施例的全面理解。然而,明显地,一个或多个实施例在没有这些具体细节的情况下也可以被实施。此外,在以下说明中,省略了对公知结构和技术的描述,以避免不必要地混淆本公开的概念。Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

在此使用的术语仅仅是为了描述具体实施例,而并非意在限制本公开。在此使用的术语“包括”、“包含”等表明了所述特征、步骤、操作和/或部件的存在,但是并不排除存在或添加一个或多个其他特征、步骤、操作或部件。The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "include", "comprising", etc. used herein indicate the existence of the features, steps, operations and/or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

在此使用的所有术语(包括技术和科学术语)具有本领域技术人员通常所理解的含义,除非另外定义。应注意,这里使用的术语应解释为具有与本说明书的上下文相一致的含义,而不应以理想化或过于刻板的方式来解释。All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

在使用类似于“A、B和C等中至少一个”这样的表述的情况下,一般来说应该按照本领域技术人员通常理解该表述的含义来予以解释(例如,“具有A、B和C中至少一个的系统”应包括但不限于单独具有A、单独具有B、单独具有C、具有A和B、具有A和C、具有B和C、和/或具有A、B、C的系统等)。When using expressions such as "at least one of A, B, and C", they should generally be interpreted according to the meaning of the expression commonly understood by technical personnel in this field (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and/or A, B, C, etc.).

在一种技术方案中,客户端与服务端进行交互的过程中,客户端会向服务端发送服务请求,然后服务端对服务请求进行处理,服务端处理完毕后会将响应消息返回至客户端。若服务端未能及时通过同步消息传输通道向客户端返回响应消息,同步消息传输通道会断开连接,导致服务端无法将响应消息返回至客户端,进而造成客户端与服务端交互异常。In one technical solution, during the interaction between the client and the server, the client sends a service request to the server, and then the server processes the service request. After the server completes the processing, it returns a response message to the client. If the server fails to return a response message to the client through the synchronous message transmission channel in time, the synchronous message transmission channel will be disconnected, resulting in the server being unable to return the response message to the client, thereby causing abnormal interaction between the client and the server.

本公开的实施例提供了一种请求响应方法,该方法包括:向服务端发送服务请求;对服务端响应服务请求进行监测;响应于监测到服务端响应超时而断开服务端和客户端之间的同步消息传输通道,创建用于重新连接客户端和服务端的异步消息传输通道;以及通过异步消息传输通道,接收来自服务端的针对服务请求的响应消息。本公开的实施例提供的技术方案,可以在同步消息传输通道由于超时而断开后创建异步消息传输通道,从而确保客户端接收到响应消息。The embodiment of the present disclosure provides a request response method, which includes: sending a service request to a server; monitoring the server's response to the service request; disconnecting the synchronous message transmission channel between the server and the client in response to monitoring that the server's response has timed out, creating an asynchronous message transmission channel for reconnecting the client and the server; and receiving a response message to the service request from the server through the asynchronous message transmission channel. The technical solution provided by the embodiment of the present disclosure can create an asynchronous message transmission channel after the synchronous message transmission channel is disconnected due to a timeout, thereby ensuring that the client receives the response message.

图1示意性示出了根据本公开实施例的可以应用请求响应方法和装置的示例性系统架构100。需要注意的是,图1所示仅为可以应用本公开实施例的系统架构的示例,以帮助本领域技术人员理解本公开的技术内容,但并不意味着本公开实施例不可以用于其他设备、系统、环境或场景。FIG1 schematically shows an exemplary system architecture 100 to which the request response method and apparatus according to an embodiment of the present disclosure can be applied. It should be noted that FIG1 is only an example of a system architecture to which the embodiment of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but does not mean that the embodiment of the present disclosure cannot be used in other devices, systems, environments or scenarios.

如图1所示,根据该实施例的系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线和/或无线通信链路等等。As shown in Fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and/or wireless communication links, etc.

用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端和/或社交平台软件等(仅为示例)。Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and/or social platform software, etc. (only as examples).

终端设备101、102、103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

服务器105可以是提供各种服务的服务器,例如对用户利用终端设备101、102、103所浏览的网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的客户端发送的请求等数据进行分析等处理,并将处理结果(例如根据客户端发送的请求生成的响应消息等)反馈给终端设备。The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the data such as the request sent by the client, and feed back the processing result (such as a response message generated according to the request sent by the client) to the terminal device.

需要说明的是,本公开实施例所提供的请求响应方法一般可以由服务器105执行。相应地,本公开实施例所提供的消息处理装置一般可以设置于服务器105中。本公开实施例所提供的服务请求响应方法也可以由不同于服务器105且能够与终端设备101、102、103和/或服务器105通信的服务器或服务器集群执行。相应地,本公开实施例所提供的消息处理装置也可以设置于不同于服务器105且能够与终端设备101、102、103和/或服务器105通信的服务器或服务器集群中。或者,本公开实施例所提供的请求响应方法也可以由终端设备101、102、或103执行,或者也可以由不同于终端设备101、102、或103的其他终端设备执行。相应地,本公开实施例所提供的消息处理装置也可以设置于终端设备101、102、或103中,或设置于不同于终端设备101、102、或103的其他终端设备中。It should be noted that the request response method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the message processing device provided in the embodiment of the present disclosure can generally be set in the server 105. The service request response method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and/or the server 105. Accordingly, the message processing device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and/or the server 105. Alternatively, the request response method provided in the embodiment of the present disclosure can also be executed by the terminal device 101, 102, or 103, or it can also be executed by other terminal devices different from the terminal device 101, 102, or 103. Accordingly, the message processing device provided in the embodiment of the present disclosure can also be set in the terminal device 101, 102, or 103, or it can be set in other terminal devices different from the terminal device 101, 102, or 103.

例如,待处理的服务请求可以由终端设备101、102、或103中的任意一个(例如,终端设备101,但不限于此)响应于用户的触摸操作而生成。然后,终端设备101可以在本地执行本公开实施例所提供的请求响应方法,或者将待处理的服务请求发送到其他终端设备、服务器、或服务器集群,并由接收该待处理的请求的其他终端设备、服务器、或服务器集群来执行本公开实施例所提供的请求响应方法。For example, the service request to be processed may be generated by any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto) in response to a user's touch operation. Then, the terminal device 101 may locally execute the request response method provided in the embodiment of the present disclosure, or send the service request to be processed to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the request to be processed execute the request response method provided in the embodiment of the present disclosure.

应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the number of terminal devices, networks and servers in Figure 1 is only illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

图2示意性示出了根据本公开实施例的请求响应方法的流程图。FIG2 schematically shows a flow chart of a request response method according to an embodiment of the present disclosure.

如图2所示,该请求响应方法包括操作S210~S240。该请求响应方法可以由客户端执行。As shown in Fig. 2, the request response method includes operations S210 to S240. The request response method may be executed by a client.

在操作S210,向服务端发送服务请求。In operation S210, a service request is sent to a service end.

例如,客户端向服务端发送服务请求,以便获取服务端返回的响应消息。For example, the client sends a service request to the server in order to obtain a response message returned by the server.

在操作S220,对服务端响应服务请求进行监测。In operation S220, the response of the server to the service request is monitored.

在一种示例中,客户端可以对服务端进行轮询来实现监测过程。例如,客户端以第一预定时间间隔向服务端发送监测请求,并确定服务端是否对服务请求进行响应。In one example, the client may poll the server to implement the monitoring process. For example, the client sends a monitoring request to the server at a first predetermined time interval, and determines whether the server responds to the service request.

在另一种示例中,可以利用超时处理函数对客户端等待服务端响应服务请求消耗的时长进行监测。下文将客户端等待服务端响应服务请求消耗的时长简称为等待时长,等待时长可以表示从客户端发送服务端请求至当前时刻之间的时长。若客户端的等待时长大于等于预设的超时时长,而客户端仍未接收到响应消息,则表示发生超时事件。若客户端的等待时长小于预设的超时时长,并且客户端接收到响应消息,则表示发生未超时事件。在实际应用中,可以利用客户端状态码来体现客户端是否发生超时事件。例如,在客户端发生超时事件时,客户端的状态码可以是504。In another example, a timeout processing function can be used to monitor the time consumed by the client waiting for the server to respond to the service request. The time consumed by the client waiting for the server to respond to the service request is referred to as the waiting time below, and the waiting time can represent the time from the client sending the server request to the current moment. If the client's waiting time is greater than or equal to the preset timeout period, and the client still has not received a response message, it means that a timeout event has occurred. If the client's waiting time is less than the preset timeout period, and the client receives a response message, it means that a non-timeout event has occurred. In actual applications, the client status code can be used to reflect whether a timeout event has occurred on the client. For example, when a timeout event occurs on the client, the client's status code can be 504.

在操作S230,响应于监测到服务端响应超时而断开服务端和客户端之间的同步消息传输通道,创建用于重新连接客户端和服务端的异步消息传输通道。In operation S230 , in response to detecting that the server response times out, the synchronous message transmission channel between the server and the client is disconnected, and an asynchronous message transmission channel is created for reconnecting the client and the server.

例如,可以在监测到等待时长大于等于预设的超时时长的情况下,创建异步消息传输通道。消息传输通道用于重新连接客户端和服务端,以便在客户端和服务端之间传输消息。For example, when it is detected that the waiting time is greater than or equal to the preset timeout time, an asynchronous message transmission channel can be created. The message transmission channel is used to reconnect the client and the server so as to transmit messages between the client and the server.

在操作S240,通过异步消息传输通道,接收来自服务端的针对服务请求的响应消息。In operation S240, a response message to the service request is received from the server through the asynchronous message transmission channel.

在客户端与服务端进行数据交互时,客户端由于网络堵塞等原因而超时断开后,服务端仍会处理客户端的请求。但是由于客户端已经断开,导致针对该请求的响应消息无法通过同步消息传输通道发送至客户端,因此创建异步的消息传输通道来传输响应消息。When the client and the server are interacting with each other, if the client times out due to network congestion or other reasons, the server will still process the client's request. However, since the client has been disconnected, the response message for the request cannot be sent to the client through the synchronous message transmission channel, so an asynchronous message transmission channel is created to transmit the response message.

根据本公开实施例提供的技术方案,在客户端和服务端之间的同步消息传输通道由于超时而断开后,可以创建异步消息传输通道,然后服务端利用异步消息传输通道将响应消息发送至客户端,因此能够确保服务端接收到响应消息,同时避免用户重复发送服务请求来获取响应消息,从而提高用户体验。According to the technical solution provided by the embodiment of the present disclosure, after the synchronous message transmission channel between the client and the server is disconnected due to timeout, an asynchronous message transmission channel can be created, and then the server uses the asynchronous message transmission channel to send a response message to the client, thereby ensuring that the server receives the response message and avoiding the user from repeatedly sending service requests to obtain the response message, thereby improving the user experience.

根据本公开另一实施例,上述操作S230可以包括以下操作:响应于监测到同步消息传输通道已断开,创建客户端的套接字。然后利用客户端的套接字向服务端的套接字发送连接请求,以便服务端的套接字对连接请求进行处理后得到连接响应。然后响应于接收到来自服务端的套接字的连接响应,创建异步消息传输通道。According to another embodiment of the present disclosure, the above operation S230 may include the following operations: in response to monitoring that the synchronous message transmission channel has been disconnected, create a socket of the client. Then use the socket of the client to send a connection request to the socket of the server, so that the socket of the server processes the connection request and obtains a connection response. Then, in response to receiving the connection response from the socket of the server, create an asynchronous message transmission channel.

例如,可以基于WebSocket(一种在单个TCP连接上进行全双工通信的协议)创建消息传输通道。创建过程如下:首先,客户端的套接字向服务端发送连接请求,要连接的目标是服务端端的套接字。连接请求中包括服务端的套接字的地址和端口号。然后,在服务端已创建套接字的情况下,服务端的套接字在检测到连接请求后,会对连接请求进行处理,并向客户端发送连接响应。然后,客户端接收到连接响应并确认连接响应,即可创建客户端与服务端之间的异步消息传输通道。For example, a message transmission channel can be created based on WebSocket (a protocol for full-duplex communication on a single TCP connection). The creation process is as follows: First, the client's socket sends a connection request to the server, and the target to be connected is the server's socket. The connection request includes the address and port number of the server's socket. Then, if the server has created a socket, the server's socket will process the connection request after detecting the connection request and send a connection response to the client. Then, the client receives the connection response and confirms the connection response, and the asynchronous message transmission channel between the client and the server is created.

在实际应用中,若在客户端发送连接请求之后,服务端还未创建套接字,客户端可以按照第二预定时间间隔重复向服务端发送连接请求,直至接收到来自服务端的针对连接请求的连接响应。In actual applications, if the server has not created a socket after the client sends a connection request, the client may repeatedly send a connection request to the server at a second predetermined time interval until receiving a connection response to the connection request from the server.

本公开实施例利用套接字实现客户端和服务端之间的通信,可以使客户端和服务端之间较为便捷且快速地重新建立连接。The disclosed embodiment utilizes a socket to implement communication between a client and a server, and can enable the client and the server to re-establish a connection more conveniently and quickly.

在一种示例中,可以监测客户端,并在监测到客户端超时的情况下创建客户端的套接字。在另一种示例中,可以监测服务端,例如监测到服务端产生的中断信息之后创建客户端的套接字。In one example, the client can be monitored, and a socket of the client can be created when a client timeout is detected. In another example, the server can be monitored, and a socket of the client can be created after, for example, an interruption message generated by the server is detected.

需要说明的是,客户端与服务端进行数据交互的过程中,客户端中断连接后,服务端会继续处理请求,然后在服务端发送响应消息并发现客户端断开后,服务端才会产生中断消息。可以看出,采用监测服务端的方案时,需要等待服务端对请求处理完毕后,再创建客户端的套接字,导致客户端收到响应消息的时间滞后。因此,可以采用监测客户端的方式来确定是否创建客户端的套接字,从而更加及时地创建客户端的套接字,减少客户端通过异步消息传输通道接收响应消息所需的时间。It should be noted that during the data interaction between the client and the server, after the client disconnects, the server will continue to process the request, and then send a response message and find that the client is disconnected, the server will generate an interrupt message. It can be seen that when using the solution of monitoring the server, it is necessary to wait for the server to complete processing the request before creating the client's socket, resulting in a time lag for the client to receive the response message. Therefore, the client monitoring method can be used to determine whether to create the client's socket, so as to create the client's socket more timely and reduce the time required for the client to receive the response message through the asynchronous message transmission channel.

根据本公开另一实施例,上述请求响应方法还可以包括以下操作:在创建用于重新连接客户端和服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,连接池中存储有客户端向服务端发送的服务请求。然后在连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建异步消息传输通道。According to another embodiment of the present disclosure, the request response method may further include the following operations: before creating an asynchronous message transmission channel for reconnecting the client and the server, obtaining the operation status information of the connection pool, wherein the connection pool stores the service request sent by the client to the server. Then, when the operation status information of the connection pool meets the preset operation conditions, triggering the creation operation to create the asynchronous message transmission channel.

例如,预设运行条件可以包括第一条件和第二条件中的至少一个。第一条件包括:连接池中存储的请求数量大于或等于第一预设阈值,第一预设阈值可以是100。第二条件包括:连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值,第二预设阈值可以是0.9。For example, the preset operating condition may include at least one of a first condition and a second condition. The first condition includes: the number of requests stored in the connection pool is greater than or equal to a first preset threshold, which may be 100. The second condition includes: the ratio of the number of requests stored in the connection pool to the maximum number of requests is greater than or equal to a second preset threshold, which may be 0.9.

连接池的运行状态信息满足预设运行条件可以表示负载过大无法对服务请求进行及时有效地处理,发生超时事件的风险较高,因此可以创建异步消息传输通道,从而确保客户端接收到来自服务端的响应消息。If the running status information of the connection pool meets the preset running conditions, it may mean that the load is too large to process the service request in a timely and effective manner, and the risk of a timeout event is high. Therefore, an asynchronous message transmission channel can be created to ensure that the client receives the response message from the server.

根据本公开另一实施例,上述请求响应方法还可以包括以下操作:在创建用于重新连接客户端和服务端的异步消息传输通道之后,输出用于提示等待响应信息的提示信息。According to another embodiment of the present disclosure, the request response method may further include the following operation: after creating an asynchronous message transmission channel for reconnecting the client and the server, outputting prompt information for prompting to wait for response information.

例如,提示信息可以包括声音、语音、显示提示内容等。提示内容可以包括等待时长的数值,也可以包括提示用户暂时等待等内容。通过提示消息可以使用户直观了解客户端与服务端的数据交互情况。For example, the prompt information may include sound, voice, display prompt content, etc. The prompt content may include the value of the waiting time, or may include prompting the user to wait temporarily, etc. The prompt message can enable the user to intuitively understand the data interaction between the client and the server.

本公开实施例通过提示信息来提示用户暂时等待,而不是提示用户出现错误,从而提供更好的用户体验。The embodiment of the present disclosure prompts the user to wait temporarily through prompt information instead of prompting the user that an error occurs, thereby providing a better user experience.

在另一些实施例中,当等待时长较长时,例如等待时长大于1分钟,也可以输出用于提示异常的异常提示信息,用户可以根据该提示消息控制客户端重新发送请求,从而及时获取响应消息。In other embodiments, when the waiting time is long, for example, the waiting time is greater than 1 minute, an abnormal prompt message for indicating the abnormality may also be output, and the user may control the client to resend the request according to the prompt message, thereby obtaining a response message in time.

图3示意性示出了根据本公开另一实施例的请求响应方法的流程图。FIG3 schematically shows a flow chart of a request response method according to another embodiment of the present disclosure.

如图3所示,该请求响应方法包括操作S310~S320。该请求响应方法可以由服务端执行。As shown in Fig. 3, the request response method includes operations S310 to S320. The request response method can be executed by the server.

在操作S310,响应于接收到来自客户端的服务请求,对服务请求进行处理,得到响应消息。In operation S310, in response to receiving a service request from a client, the service request is processed to obtain a response message.

在操作S320,响应于监测到客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向客户端发送响应消息。其中,异步消息传输通道是在服务端响应超时而断开同步消息传输通道的情况下创建的,异步消息传输通道用于重新连接客户端和服务端。In operation S320, in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected, a response message is sent to the client through an asynchronous message transmission channel. The asynchronous message transmission channel is created when the server responds to a timeout and disconnects the synchronous message transmission channel, and the asynchronous message transmission channel is used to reconnect the client and the server.

需要说明的是,服务端对请求进行处理后得到响应消息,若未发生超时时间,服务端可以利用同步消息传输通道将响应消息发送至客户端。若发生超时事件,服务端可以利用异步消息传输通道将响应消息发送至客户端。It should be noted that after the server processes the request and obtains a response message, if no timeout occurs, the server can use the synchronous message transmission channel to send the response message to the client. If a timeout event occurs, the server can use the asynchronous message transmission channel to send the response message to the client.

根据本公开实施例提供的技术方案,在客户端和服务端之间的同步消息传输通道由于超时而断开之后,服务端可以通过异步消息传输通道向客户端发送响应消息,从而避免客户端由于超时而提示异常,还能够避免用户重复操作来获取响应消息,从而提高用户体验。According to the technical solution provided by the embodiments of the present disclosure, after the synchronous message transmission channel between the client and the server is disconnected due to timeout, the server can send a response message to the client through the asynchronous message transmission channel, thereby avoiding the client prompting an exception due to timeout, and avoiding the user from repeating operations to obtain the response message, thereby improving the user experience.

根据本公开另一实施例,上述请求响应方法还可以包括以下操作:在通过异步消息传输通道向客户端发送响应消息之前,创建服务端的套接字。然后在服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对连接请求进行处理,得到连接响应。向客户端的套接字发送连接响应,以便创建异步消息传输通道。客户端的套接字是客户端在监测到服务端响应超时而断开同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the request response method may further include the following operations: before sending a response message to the client through the asynchronous message transmission channel, create a socket on the server side. Then, when the socket on the server side detects a connection request from the socket on the client side, process the connection request to obtain a connection response. Send a connection response to the socket on the client side to create an asynchronous message transmission channel. The socket on the client side is created when the client detects that the response of the server side has timed out and disconnects the synchronous message transmission channel.

例如,客户端中断连接后,服务端会继续处理请求,然后可以在服务端发送响应消息并发现客户端断开后创建服务端的套接字。然后利用服务端的套接字接收来自客户端的套接字的连接请求,并对连接请求进行处理,然后向客户端的套接字发送连接响应。For example, after the client disconnects, the server will continue to process the request, and then the server can send a response message and create a server socket after discovering that the client is disconnected. Then use the server socket to receive the connection request from the client socket, process the connection request, and then send a connection response to the client socket.

本公开实施例利用套接字实现客户端和服务端之间的通信,可以使客户端和服务端之间较为便捷且快速地重新建立连接。The disclosed embodiment utilizes a socket to implement communication between a client and a server, and can enable the client and the server to re-establish a connection more conveniently and quickly.

根据本公开另一实施例,上述响应于监测到客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向客户端发送响应消息的操作,可以包括以下操作:响应于监测到指示同步消息传输通道断开的中断消息,根据中断消息,从多个候选响应消息中确定针对服务请求的响应消息。然后通过异步消息传输通道向客户端发送响应消息。According to another embodiment of the present disclosure, the above-mentioned operation of sending a response message to the client through an asynchronous message transmission channel in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected may include the following operations: in response to monitoring an interrupt message indicating that the synchronous message transmission channel is disconnected, determining a response message for the service request from multiple candidate response messages according to the interrupt message. Then, the response message is sent to the client through the asynchronous message transmission channel.

例如,当服务端由于客户端中断而产生中断消息,可以监测到中断消息,然后服务端可以根据中断消息中从多个候选响应消息中,确定无法通过同步消息传输通道返回至客户端的响应消息,例如根据中断消息包括的标识信息确定响应消息,然后将响应消息通过消息传输通过发送至客户端。For example, when the server generates an interruption message due to a client interruption, the interruption message can be monitored, and then the server can determine the response message that cannot be returned to the client through the synchronous message transmission channel from multiple candidate response messages in the interruption message, such as determining the response message based on the identification information included in the interruption message, and then sending the response message to the client through the message transmission.

本公开实施例利用中断消息从多个候选响应消息中确定响应消息,从而确保将正确的响应消息返回至客户端。The embodiment of the present disclosure utilizes an interrupt message to determine a response message from a plurality of candidate response messages, thereby ensuring that a correct response message is returned to the client.

以下以一个具体实施例,对本公开实施例提供的请求响应方法进行说明。本实施例涉及客户端和服务端。The request response method provided by the embodiment of the present disclosure is described below with a specific embodiment. This embodiment involves a client and a server.

客户端向服务端发送服务请求,然后客户端对服务端响应服务请求进行监测,来确定是否发生超时而造成同步消息传输通道断开。若否,则客户端可以等待响应消息;若是,则客户端创建客户端的套接字,然后利用客户端的套接字向服务端的套接字发送连接请求。The client sends a service request to the server, and then the client monitors the server's response to the service request to determine whether a timeout occurs and causes the synchronous message transmission channel to be disconnected. If not, the client can wait for the response message; if so, the client creates a client socket, and then uses the client socket to send a connection request to the server socket.

在客户端向服务端发送服务请求之后,服务端接收到来自客户端的服务请求,然后服务端处理服务请求,得到响应消息。在服务端得到响应消息之后,服务端确定同步消息传输通道是否断开。若否,则通过同步消息传输通道向客户端发送响应消息。若是,则服务端创建服务端的套接字。After the client sends a service request to the server, the server receives the service request from the client, and then processes the service request and obtains a response message. After the server receives the response message, the server determines whether the synchronous message transmission channel is disconnected. If not, the server sends a response message to the client through the synchronous message transmission channel. If so, the server creates a socket for the server.

由于客户端的套接字向服务端的套接字发送连接请求,因此服务端的套接字监测到来自客户端的套接字的连接请求之后,服务端可以处理连接请求,得到连接响应。然后服务端的套接字向客户端的套接字发送连接响应。Since the client's socket sends a connection request to the server's socket, after the server's socket detects the connection request from the client's socket, the server can process the connection request and obtain a connection response. Then the server's socket sends a connection response to the client's socket.

然后,客户端接收到来自服务端的连接响应之后,客户端确认连接响应,从而创建异步消息传输通道。Then, after the client receives the connection response from the server, the client confirms the connection response, thereby creating an asynchronous message transmission channel.

然后服务端可以通过异步消息传输通道向客户端发送响应消息。The server can then send a response message to the client through the asynchronous message transmission channel.

图4示意性示出了根据本公开实施例的请求响应装置的框图。FIG4 schematically shows a block diagram of a request response device according to an embodiment of the present disclosure.

如图4所示,请求响应装置400可以包括第一发送模块410、监测模块420、第一创建模块430以及接收模块440。As shown in FIG. 4 , the request response device 400 may include a first sending module 410 , a monitoring module 420 , a first creating module 430 and a receiving module 440 .

第一发送模块410用于向服务端发送服务请求。The first sending module 410 is used to send a service request to the server.

监测模块420用于对服务端响应服务请求进行监测。The monitoring module 420 is used to monitor the server's response to the service request.

第一创建模块430用于响应于监测到服务端响应超时而断开服务端和客户端之间的同步消息传输通道,创建用于重新连接客户端和服务端的异步消息传输通道。The first creation module 430 is used for disconnecting the synchronous message transmission channel between the server and the client in response to detecting a server response timeout, and creating an asynchronous message transmission channel for reconnecting the client and the server.

接收模块440用于通过异步消息传输通道,接收来自服务端的针对服务请求的响应消息。The receiving module 440 is used to receive a response message to the service request from the server through an asynchronous message transmission channel.

根据本公开另一实施例,第一创建模块包括第一创建子模块、第一发送子模块和第二创建子模块。第一创建子模块用于响应于监测到同步消息传输通道已断开,创建客户端的套接字。第一发送子模块用于利用客户端的套接字向服务端的套接字发送连接请求,以便服务端的套接字对连接请求进行处理后得到连接响应。第二创建子模块用于响应于接收到来自服务端的套接字的连接响应,创建异步消息传输通道。According to another embodiment of the present disclosure, the first creation module includes a first creation submodule, a first sending submodule and a second creation submodule. The first creation submodule is used to create a socket of the client in response to monitoring that the synchronous message transmission channel has been disconnected. The first sending submodule is used to use the socket of the client to send a connection request to the socket of the server, so that the socket of the server processes the connection request and obtains a connection response. The second creation submodule is used to create an asynchronous message transmission channel in response to receiving a connection response from the socket of the server.

根据本公开另一实施例,上述请求响应装置还包括获取模块和触发模块。获取模块用于在创建用于重新连接客户端和服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,连接池中存储有客户端向服务端发送的服务请求。触发模块用于在连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建异步消息传输通道。According to another embodiment of the present disclosure, the request response device further includes an acquisition module and a trigger module. The acquisition module is used to acquire the operation status information of the connection pool before creating an asynchronous message transmission channel for reconnecting the client and the server, wherein the connection pool stores the service request sent by the client to the server. The trigger module is used to trigger the creation operation to create the asynchronous message transmission channel when the operation status information of the connection pool meets the preset operation conditions.

根据本公开另一实施例,预设运行条件包括连接池中存储的请求数量大于或等于第一预设阈值;以及/或者连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。According to another embodiment of the present disclosure, the preset operating conditions include that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the ratio of the number of requests stored in the connection pool to the maximum number of requests is greater than or equal to a second preset threshold.

根据本公开另一实施例,监测模块包括监测子模块,用于利用超时处理函数对客户端等待服务端响应服务请求消耗的时长进行监测。According to another embodiment of the present disclosure, the monitoring module includes a monitoring submodule for monitoring the time consumed by the client waiting for the server to respond to the service request by using a timeout processing function.

根据本公开另一实施例,上述请求响应装置还包括提示模块,用于在创建用于重新连接客户端和服务端的异步消息传输通道之后,输出用于提示等待响应信息的提示信息。According to another embodiment of the present disclosure, the request response device further includes a prompt module for outputting prompt information for waiting for response information after creating an asynchronous message transmission channel for reconnecting the client and the server.

图5示意性示出了根据本公开另一实施例的请求响应装置的框图。FIG5 schematically shows a block diagram of a request response device according to another embodiment of the present disclosure.

如图5所示,请求响应装置500可以包括第一处理模块510和第二发送模块520。As shown in FIG. 5 , the request response device 500 may include a first processing module 510 and a second sending module 520 .

第一处理模块510用于响应于接收到来自客户端的服务请求,对服务请求进行处理,得到响应消息。The first processing module 510 is used for processing the service request in response to receiving the service request from the client to obtain a response message.

第二发送模块520用于响应于监测到客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向客户端发送响应消息。异步消息传输通道是在服务端响应超时而断开同步消息传输通道的情况下创建的,异步消息传输通道用于重新连接客户端和服务端。The second sending module 520 is used to send a response message to the client through the asynchronous message transmission channel in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected. The asynchronous message transmission channel is created when the server responds to timeout and disconnects the synchronous message transmission channel. The asynchronous message transmission channel is used to reconnect the client and the server.

根据本公开另一实施例,上述请求响应装置还包括第二创建模块、第二处理模块和第三发送模块。第二创建模块用于在通过异步消息传输通道向客户端发送响应消息之前,创建服务端的套接字。第二处理模块用于在服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对连接请求进行处理,得到连接响应。第三发送模块用于向客户端的套接字发送连接响应,以便创建异步消息传输通道。客户端的套接字是客户端在监测到服务端响应超时而断开同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the request response device further includes a second creation module, a second processing module and a third sending module. The second creation module is used to create a socket on the server side before sending a response message to the client through the asynchronous message transmission channel. The second processing module is used to process the connection request and obtain a connection response when the socket on the server side detects a connection request from the socket on the client side. The third sending module is used to send a connection response to the socket on the client side so as to create an asynchronous message transmission channel. The socket on the client side is created when the client disconnects the synchronous message transmission channel after detecting that the response of the server side has timed out.

根据本公开另一实施例,第二发送模块包括确定子模块和第二发送子模块。确定子模块用于响应于监测到指示同步消息传输通道断开的中断消息,根据中断消息,从多个候选响应消息中确定针对服务请求的响应消息。第二发送子模块用于通过异步消息传输通道向客户端发送响应消息。According to another embodiment of the present disclosure, the second sending module includes a determining submodule and a second sending submodule. The determining submodule is used to respond to an interrupt message indicating that the synchronous message transmission channel is disconnected, and determine a response message for the service request from multiple candidate response messages according to the interrupt message. The second sending submodule is used to send a response message to the client through the asynchronous message transmission channel.

需要说明的是,本公开装置部分的实施例与本公开方法部分的实施例对应相同或类似,本公开在此不再赘述。It should be noted that the embodiments of the device part of the present disclosure are the same or similar to the embodiments of the method part of the present disclosure, and the present disclosure will not repeat them here.

根据本公开的实施例的模块和子模块中的任意多个、或其中任意多个的至少部分功能可以在一个模块中实现。根据本公开实施例的模块和子模块中的任意一个或多个可以被拆分成多个模块来实现。根据本公开实施例的模块和子模块中的任意一个或多个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式的硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,根据本公开实施例的模块和子模块中的一个或多个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。According to the embodiments of the present invention, any one or more of the modules and submodules, or at least part of the functions of any one of them, can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules and submodules can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules and submodules can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in any one of the three implementation methods of software, hardware and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules and submodules can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.

例如,第一发送模块、监测模块、第一创建模块以及接收模块中的任意多个可以合并在一个模块/单元/子单元中实现,或者其中的任意一个模块/单元/子单元可以被拆分成多个模块/单元/子单元。或者,这些模块/单元/子单元中的一个或多个模块/单元/子单元的至少部分功能可以与其他模块/单元/子单元的至少部分功能相结合,并在一个模块/单元/子单元中实现。根据本公开的实施例,第一发送模块、监测模块、第一创建模块以及接收模块中的至少一个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式等硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,第一发送模块、监测模块、第一创建模块以及接收模块中的至少一个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。For example, any multiple of the first sending module, the monitoring module, the first creation module, and the receiving module can be combined in one module/unit/sub-unit for implementation, or any one of the modules/units/sub-units can be split into multiple modules/units/sub-units. Alternatively, at least part of the functions of one or more modules/units/sub-units in these modules/units/sub-units can be combined with at least part of the functions of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the first sending module, the monitoring module, the first creation module, and the receiving module can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware or in any appropriate combination of any of them. Alternatively, at least one of the first sending module, the monitoring module, the first creation module, and the receiving module can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

图6示意性示出了根据本公开实施例的适于实现上文描述的方法和装置的电子设备的框图。图6示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Fig. 6 schematically shows a block diagram of an electronic device suitable for implementing the method and apparatus described above according to an embodiment of the present disclosure. The electronic device shown in Fig. 6 is only an example and should not bring any limitation to the functions and scope of use of the embodiment of the present disclosure.

如图6所示,根据本公开实施例的电子设备600包括处理器601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。处理器601例如可以包括通用微处理器(例如CPU)、指令集处理器和/或相关芯片组和/或专用微处理器(例如,专用集成电路(ASIC)),等等。处理器601还可以包括用于缓存用途的板载存储器。处理器601可以包括用于执行根据本公开实施例的方法流程的不同动作的单一处理单元或者是多个处理单元。As shown in FIG6 , the electronic device 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and/or a related chipset and/or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

在RAM 603中,存储有电子设备600操作所需的各种程序和数据。处理器601、ROM602以及RAM 603通过总线604彼此相连。处理器601通过执行ROM 602和/或RAM 603中的程序来执行根据本公开实施例的方法流程的各种操作。需要注意,所述程序也可以存储在除ROM 602和RAM 603以外的一个或多个存储器中。处理器601也可以通过执行存储在所述一个或多个存储器中的程序来执行根据本公开实施例的方法流程的各种操作。In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other through bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and/or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

根据本公开的实施例,电子设备600还可以包括输入/输出(I/O)接口605,输入/输出(I/O)接口605也连接至总线604。电子设备600还可以包括连接至I/O接口605的以下部件中的一项或多项:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。According to an embodiment of the present disclosure, the electronic device 600 may further include an input/output (I/O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I/O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.

根据本公开的实施例,根据本公开实施例的方法流程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读存储介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被处理器601执行时,执行本公开实施例的系统中限定的上述功能。根据本公开的实施例,上文描述的系统、设备、装置、模块、单元等可以通过计算机程序模块来实现。According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and/or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

本公开还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例中描述的设备/装置/系统中所包含的;也可以是单独存在,而未装配入该设备/装置/系统中。上述计算机可读存储介质承载有一个或者多个程序,当上述一个或者多个程序被执行时,实现根据本公开实施例的方法。The present disclosure also provides a computer-readable storage medium, which may be included in the device/apparatus/system described in the above embodiments; or may exist independently without being assembled into the device/apparatus/system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

根据本公开的实施例,计算机可读存储介质可以是非易失性的计算机可读存储介质。例如可以包括但不限于:便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

例如,根据本公开的实施例,计算机可读存储介质可以包括上文描述的ROM 602和/或RAM 603和/或ROM 602和RAM 603以外的一个或多个存储器。For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 602 and/or the RAM 603 described above and/or one or more memories other than the ROM 602 and the RAM 603 .

附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

本领域技术人员可以理解,本公开的各个实施例和/或权利要求中记载的特征可以进行多种组合和/或结合,即使这样的组合或结合没有明确记载于本公开中。特别地,在不脱离本公开精神和教导的情况下,本公开的各个实施例和/或权利要求中记载的特征可以进行多种组合和/或结合。所有这些组合和/或结合均落入本公开的范围。It will be appreciated by those skilled in the art that the features described in the various embodiments and/or claims of the present disclosure may be combined and/or combined in a variety of ways, even if such combinations and/or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and/or claims of the present disclosure may be combined and/or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and/or combinations fall within the scope of the present disclosure.

以上对本公开的实施例进行了描述。但是,这些实施例仅仅是为了说明的目的,而并非为了限制本公开的范围。尽管在以上分别描述了各实施例,但是这并不意味着各个实施例中的措施不能有利地结合使用。本公开的范围由所附权利要求及其等同物限定。不脱离本公开的范围,本领域技术人员可以做出多种替代和修改,这些替代和修改都应落在本公开的范围之内。The embodiments of the present disclosure are described above. However, these embodiments are only for the purpose of illustration and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims (10)

1.一种请求响应方法,包括:1. A request response method, comprising: 向服务端发送服务请求;Send a service request to the server; 对所述服务端响应所述服务请求进行监测;Monitoring the response of the server to the service request; 响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道;以及In response to detecting that the server responds timeout, disconnecting the synchronous message transmission channel between the server and the client, creating an asynchronous message transmission channel for reconnecting the client and the server; and 通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息;Receiving, via the asynchronous message transmission channel, a response message to the service request from the server; 其中,所述对所述服务端响应所述服务请求进行监测包括:The monitoring of the server's response to the service request includes: 利用超时处理函数对客户端等待所述服务端响应所述服务请求消耗的时长进行监测,其中,在所述客户端的等待时长大于或等于预设的超时时长且所述客户端仍未接收到响应消息的情况下,确定发生超时事件;在所述客户端的所述等待时长小于所述预设的超时时长且所述客户端接收到所述响应消息的情况下,确定发生未超时事件;The time length that the client waits for the server to respond to the service request is monitored by using a timeout processing function, wherein, when the waiting time length of the client is greater than or equal to a preset timeout length and the client still has not received a response message, it is determined that a timeout event has occurred; when the waiting time length of the client is less than the preset timeout length and the client has received the response message, it is determined that a non-timeout event has occurred; 其中,所述响应于监测到所述服务端响应超时而断开所述服务端和所述客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道包括:The disconnecting of the synchronous message transmission channel between the server and the client in response to monitoring that the server response has timed out, and creating an asynchronous message transmission channel for reconnecting the client and the server includes: 响应于监测到所述服务端超时且所述同步消息传输通道已断开,创建所述客户端的套接字;In response to monitoring that the server has timed out and the synchronous message transmission channel has been disconnected, creating a socket for the client; 利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应;Using the socket of the client to send a connection request to the socket of the server, so that the socket of the server processes the connection request and obtains a connection response; 响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。In response to receiving a connection response from the socket of the server, the asynchronous message transmission channel is created. 2.根据权利要求1所述的方法,还包括:2. The method according to claim 1, further comprising: 在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,所述连接池中存储有所述客户端向所述服务端发送的服务请求;以及Before creating an asynchronous message transmission channel for reconnecting the client and the server, obtaining operation status information of a connection pool, wherein the connection pool stores a service request sent by the client to the server; and 在所述连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建所述异步消息传输通道。When the operation status information of the connection pool meets the preset operation condition, a creation operation is triggered to create the asynchronous message transmission channel. 3.根据权利要求2所述的方法,其中,所述预设运行条件包括所述连接池中存储的请求数量大于或等于第一预设阈值;以及/或者所述连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。3. The method according to claim 2, wherein the preset operating conditions include that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the ratio of the number of requests stored in the connection pool to the maximum number of requests is greater than or equal to a second preset threshold. 4.根据权利要求1所述的方法,还包括:4. The method according to claim 1, further comprising: 在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之后,输出用于提示等待所述响应信息的提示信息。After creating an asynchronous message transmission channel for reconnecting the client and the server, outputting prompt information for prompting to wait for the response information. 5.一种请求响应方法,包括:5. A request response method, comprising: 响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息;In response to receiving a service request from a client, processing the service request to obtain a response message; 响应于监测到所述客户端和服务端之间的同步消息传输通道断开,在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字;In response to monitoring that the synchronous message transmission channel between the client and the server is disconnected, before sending the response message to the client through the asynchronous message transmission channel, creating a socket of the server; 在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应;When the socket of the server detects a connection request from the socket of the client, the connection request is processed to obtain a connection response; 向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道;Sending the connection response to the socket of the client to create the asynchronous message transmission channel; 通过异步消息传输通道向所述客户端发送所述响应消息;以及Sending the response message to the client through an asynchronous message transmission channel; and 其中,所述客户端的套接字是在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。The socket of the client is created when the synchronous message transmission channel is disconnected due to the timeout of the response of the server, and the asynchronous message transmission channel is used to reconnect the client and the server. 6.根据权利要求5所述的方法,所述响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息包括:6. The method according to claim 5, in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected, sending the response message to the client through the asynchronous message transmission channel comprises: 响应于监测到指示所述同步消息传输通道断开的中断消息,根据所述中断消息,从多个候选响应消息中确定针对所述服务请求的所述响应消息;以及In response to monitoring an interrupt message indicating that the synchronization message transmission channel is disconnected, determining the response message for the service request from a plurality of candidate response messages according to the interrupt message; and 通过所述异步消息传输通道向所述客户端发送所述响应消息。The response message is sent to the client through the asynchronous message transmission channel. 7.一种请求响应装置,包括:7. A request response device, comprising: 第一发送模块,用于向服务端发送服务请求;A first sending module, used to send a service request to a server; 监测模块,用于对所述服务端响应所述服务请求进行监测;A monitoring module, used to monitor the response of the server to the service request; 第一创建模块,用于响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道;以及a first creation module, configured to disconnect the synchronous message transmission channel between the server and the client in response to detecting that the server responds timeout, and to create an asynchronous message transmission channel for reconnecting the client and the server; and 接收模块,用于通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息;A receiving module, used for receiving a response message to the service request from the server through the asynchronous message transmission channel; 其中,所述监测模块包括:Wherein, the monitoring module includes: 监测子模块,用于利用超时处理函数对客户端等待所述服务端响应所述服务请求消耗的时长进行监测,其中,在所述客户端的等待时长大于或等于预设的超时时长且所述客户端仍未接收到响应消息的情况下,表示发生超时事件;在所述客户端的所述等待时长小于所述预设的超时时长且所述客户端接收到所述响应消息的情况下,表示发生未超时事件;A monitoring submodule is used to monitor the time consumed by the client waiting for the server to respond to the service request by using a timeout processing function, wherein, when the waiting time of the client is greater than or equal to a preset timeout time and the client still has not received a response message, it indicates that a timeout event has occurred; when the waiting time of the client is less than the preset timeout time and the client has received the response message, it indicates that a non-timeout event has occurred; 其中,所述第一创建模块包括:Wherein, the first creation module includes: 第一创建子模块,用于响应于监测到所述客户端超时且所述同步消息传输通道已断开,创建所述客户端的套接字;A first creation submodule, configured to create a socket of the client in response to monitoring that the client has timed out and the synchronous message transmission channel has been disconnected; 第一发送子模块,用于利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应;A first sending submodule, used for sending a connection request to the socket of the server by using the socket of the client, so that the socket of the server processes the connection request and obtains a connection response; 第二创建子模块,用于响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。The second creation submodule is used to create the asynchronous message transmission channel in response to receiving a connection response of the socket from the server. 8.一种请求响应装置,包括:8. A request response device, comprising: 第一处理模块,用于响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息;A first processing module, configured to, in response to receiving a service request from a client, process the service request to obtain a response message; 第二创建模块,用于在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字;A second creation module, used for creating a socket of the server before sending the response message to the client through an asynchronous message transmission channel; 第二处理模块,用于在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应;A second processing module is used for processing the connection request to obtain a connection response when the socket of the server detects a connection request from the socket of the client; 第三发送模块,用于向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道;A third sending module, used for sending the connection response to the socket of the client so as to create the asynchronous message transmission channel; 第二发送模块,用于响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息;A second sending module is used for sending the response message to the client through the asynchronous message transmission channel in response to monitoring that the synchronous message transmission channel between the client and the server is disconnected; 其中,所述客户端的套接字是在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。The socket of the client is created when the synchronous message transmission channel is disconnected due to the timeout of the response of the server, and the asynchronous message transmission channel is used to reconnect the client and the server. 9.一种电子设备,包括:9. An electronic device comprising: 一个或多个处理器;one or more processors; 存储器,用于存储一个或多个程序,a memory for storing one or more programs, 其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现权利要求1至6中任一项所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6. 10.一种计算机可读存储介质,其上存储有可执行指令,该指令被处理器执行时使处理器实现权利要求1至6中任一项所述的方法。10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 6.
CN202210673000.2A 2022-06-14 2022-06-14 Request response method, device, electronic device and storage medium Active CN115103005B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210673000.2A CN115103005B (en) 2022-06-14 2022-06-14 Request response method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210673000.2A CN115103005B (en) 2022-06-14 2022-06-14 Request response method, device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN115103005A CN115103005A (en) 2022-09-23
CN115103005B true CN115103005B (en) 2024-08-16

Family

ID=83291938

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210673000.2A Active CN115103005B (en) 2022-06-14 2022-06-14 Request response method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN115103005B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118101747B (en) * 2023-11-08 2024-11-12 广州市玄武无线科技股份有限公司 A method and device for automatic reconnection based on asynchronous data transmission

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107071826A (en) * 2011-03-17 2017-08-18 华为技术有限公司 The method and apparatus of transmitting data resources
CN107147663A (en) * 2017-06-02 2017-09-08 广东暨通信息发展有限公司 Synchronous communication method and system of a computer cluster system
CN112134907A (en) * 2019-06-24 2020-12-25 北京京东尚科信息技术有限公司 Message processing method, device and equipment

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7562147B1 (en) * 2000-10-02 2009-07-14 Microsoft Corporation Bi-directional HTTP-based reliable messaging protocol and system utilizing same
US7055028B2 (en) * 2000-10-10 2006-05-30 Juniper Networks, Inc. HTTP multiplexor/demultiplexor system for use in secure transactions
JP4144882B2 (en) * 2004-05-14 2008-09-03 インターナショナル・ビジネス・マシーンズ・コーポレーション Information processing apparatus, information system, proxy processing method, program, and recording medium
US7594020B2 (en) * 2005-05-31 2009-09-22 Microsoft Corporation Re-establishing a connection for an application layer via a service layer
CN103312558B (en) * 2013-05-15 2016-04-06 武汉长江通信产业集团股份有限公司 In computer clients server system, network is connected with validity monitoring method and system
CN104394212A (en) * 2014-11-23 2015-03-04 国云科技股份有限公司 A method for real-time website push message
CN106911810A (en) * 2017-04-28 2017-06-30 杭州迪普科技股份有限公司 A kind of interface interchange method and apparatus
CN108989404B (en) * 2018-06-29 2022-03-25 武汉斗鱼网络科技有限公司 A method, server, system and storage medium for distributing bullet screen messages
CN108833950B (en) * 2018-06-29 2021-05-28 武汉斗鱼网络科技有限公司 A method, server, system and storage medium for distributing bullet screen messages
CN111385287A (en) * 2020-02-20 2020-07-07 视联动力信息技术股份有限公司 Network reconnection method and device for service system
CN111669438B (en) * 2020-05-27 2022-10-04 北京百度网讯科技有限公司 Live message transmission method, device, electronic device and medium
CN111953678B (en) * 2020-08-11 2022-04-12 福州职业技术学院 Method and system for verifying DNS request security
CN112181652B (en) * 2020-09-25 2023-11-28 北京天融信网络安全技术有限公司 Method and device for adjusting capacity of connection pool, storage medium and electronic equipment
CN113986501B (en) * 2021-10-28 2024-09-03 西安热工研究院有限公司 Real-time database API (application program interface) interrupt-free calling method, system, storage medium and server

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107071826A (en) * 2011-03-17 2017-08-18 华为技术有限公司 The method and apparatus of transmitting data resources
CN107147663A (en) * 2017-06-02 2017-09-08 广东暨通信息发展有限公司 Synchronous communication method and system of a computer cluster system
CN112134907A (en) * 2019-06-24 2020-12-25 北京京东尚科信息技术有限公司 Message processing method, device and equipment

Also Published As

Publication number Publication date
CN115103005A (en) 2022-09-23

Similar Documents

Publication Publication Date Title
US10348809B2 (en) Naming of distributed business transactions
US9384114B2 (en) Group server performance correction via actions to server subset
EP3489825A1 (en) Method, apparatus and computer readable storage medium for processing service
CN113900834B (en) Data processing method, device, equipment and storage medium based on Internet of things technology
CN111478974B (en) Network connection method and device, electronic equipment and readable storage medium
CN111831503B (en) Monitoring method based on monitoring agent and monitoring agent device
CN110881224B (en) Network long connection method, device, equipment and storage medium
GB2518739A (en) Custom Correlation of a Distributed Business Transaction
CN112702229B (en) Data transmission method, device, electronic equipment and storage medium
CN112925623A (en) Task processing method and device, electronic equipment and medium
US10223407B2 (en) Asynchronous processing time metrics
WO2019062019A1 (en) Data list exporting method and terminal using same
CN115103005B (en) Request response method, device, electronic device and storage medium
US20160321173A1 (en) Automatic garbage collection thrashing monitoring
CN114257632B (en) Method and device for reconnecting broken wire, electronic equipment and readable storage medium
CN114172946B (en) Request result sending method, device, electronic equipment and computer readable medium
CN114449040A (en) Configuration issuing method and device based on cloud platform
CN113094131A (en) Prompt resource display method, device, terminal, server and storage medium
CN113760693A (en) Method and apparatus for local debugging of microservice systems
CN115118762B (en) Session processing method, client and system
TWI755005B (en) Test method based on improved rest protocol, client, server and medium
CN113760886B (en) Method, apparatus, device and computer readable medium for providing data service
CN110011767B (en) Method and apparatus for TCP connection backup
CN110912720B (en) Information generation method and device
CN116980950A (en) Information sending method, device, terminal equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant