Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
CN115103005A - Request response method and device, electronic equipment and storage medium - Google Patents
[go: Go Back, main page]

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

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

Info

Publication number
CN115103005A
CN115103005A CN202210673000.2A CN202210673000A CN115103005A CN 115103005 A CN115103005 A CN 115103005A CN 202210673000 A CN202210673000 A CN 202210673000A CN 115103005 A CN115103005 A CN 115103005A
Authority
CN
China
Prior art keywords
server
response
client
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.)
Granted
Application number
CN202210673000.2A
Other languages
Chinese (zh)
Other versions
CN115103005B (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

Images

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)
  • Communication Control (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure provides a request response method, a request response device, an electronic device and a storage medium, wherein the method comprises the following steps: sending a service request to a server; monitoring the response of the server to the service request; in response to monitoring that the response time of the server is out, disconnecting a synchronous message transmission channel between the server and the client, and establishing an asynchronous message transmission channel for reconnecting the client and the server; and receiving a response message aiming at the service request from the service end through the asynchronous message transmission channel.

Description

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

技术领域technical field

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

背景技术Background technique

在客户端与服务端进行交互的过程中,客户端一般设置有超时时长,超时时长可以是研发人员根据经验设置的。实际应用中,由于使用环境差异较大,研发人员难以准确预估超时时间,因此经常发生客户端超时的事件。发生超时事件时,客户端会向用户展示提示信息来告知用户出现异常,然后用户可以根据实际需求重复操作,再次利用客户端发送服务请求,以便获得所需的信息,上述过程会影响用户体验。During the interaction between the client and the server, the client generally sets a timeout period, and the timeout period can be set by the R&D personnel based on experience. In practical applications, due to the large differences in the use environment, it is difficult for developers to accurately estimate the timeout period, so client timeout events often occur. When a timeout event occurs, the client will show the user a prompt message to inform the user that there is an exception, and then the user can repeat the operation according to the actual needs, and use the client to send the 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, apparatus, electronic device, computer-readable storage medium, and computer program product, which can send a response message to the client through an asynchronous message transmission channel after the client terminates the connection due to timeout.

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

根据本公开另一实施例,所述响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道包括:响应于监测到所述同步消息传输通道已断开,创建所述客户端的套接字;利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应;响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。According to another embodiment of the present disclosure, the synchronous message transmission channel between the server and the client is disconnected in response to monitoring that the server response times out, and a channel for reconnecting the client and the client is created. The asynchronous message transmission channel of the server includes: in response to monitoring 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 can obtain a connection response after processing the connection request; in response to receiving the connection response from the socket of the server, the asynchronous message transmission channel is created.

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

根据本公开另一实施例,所述预设运行条件包括所述连接池中存储的请求数量大于或等于第一预设阈值;以及/或者所述连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。According to another embodiment of the present disclosure, the preset operating condition includes that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the difference between the number of requests stored in the connection pool and the maximum number of requests The ratio is greater than or equal to the 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 consumed by the client waiting for the server to respond to the service request.

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

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

根据本公开另一实施例,还包括:在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字;在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应;向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道;其中,所述客户端的套接字是所述客户端在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the method further includes: before sending the response message to the client through an asynchronous message transmission channel, creating a socket of the server; In the case of a connection request of the socket of the client, process the connection request to obtain a connection response; send the connection response to the socket of the client, so as to create the asynchronous message transmission channel; wherein, the The socket of the client is created when the client detects that the server responds to timeout 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: responding to Monitoring an interrupt message indicating that the synchronous 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 sending the response message to the service request through the asynchronous message transmission channel The client sends the response message.

本公开的另一个方面提供了一种请求响应装置,包括第一发送模块、监测模块、第一创建模块以及接收模块。第一发送模块用于向服务端发送服务请求。监测模块用于对所述服务端响应所述服务请求进行监测。第一创建模块用于响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道。接收模块用于通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息。Another aspect of the present disclosure provides a request response apparatus, including a first sending module, a monitoring module, a first creating module, and a receiving module. The first sending module is used for sending a service request to the server. The monitoring module is used for monitoring the response of the server to the service request. The first creation module is configured to disconnect the synchronous message transmission channel between the server and the client in response to monitoring that the server responds to timeout, and create an asynchronous message for reconnecting the client and the server transmission channel. The receiving module is configured to receive a response message for 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 configured to create a socket of the client in response to monitoring that the synchronization message transmission channel is disconnected. The first sending submodule is configured 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 can obtain a connection response after processing the connection request. The second creation submodule is configured 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 above-mentioned request response apparatus further includes an acquisition module and a trigger module. The obtaining module is used to obtain the running status information of the connection pool before creating the asynchronous message transmission channel for reconnecting the client and the server, wherein the connection pool stores the information sent by the client to the service service request sent by the client. The triggering module is configured to trigger a creation operation to create the asynchronous message transmission channel when the running state information of the connection pool satisfies a preset running condition.

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

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

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

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

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

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

根据本公开另一实施例,上述请求响应装置还包括第二创建模块、第二处理模块和第三发送模块。第二创建模块用于在通过异步消息传输通道向所述客户端发送所述响应消息之前,创建所述服务端的套接字。第二处理模块用于在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应。第三发送模块用于向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道。所述客户端的套接字是所述客户端在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the above-mentioned request response apparatus further includes a second creation module, a second processing module, and a third sending module. The second creation module is configured to create a socket of the server before sending the response message to the client through an asynchronous message transmission channel. The second processing module is configured to process the connection request to obtain a connection response when the socket of the server monitors the connection request from the socket of the client. The third sending module is configured 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 server responds to timeout 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 configured to, in response to monitoring an interruption message indicating that the synchronization message transmission channel is disconnected, determine the response message for the service request from a plurality of candidate response messages according to the interruption message. The second sending submodule is configured to send the response message to the client through the asynchronous message transmission channel.

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

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

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

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

附图说明Description of drawings

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

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

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

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

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

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

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

具体实施方式Detailed ways

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

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

在此使用的所有术语(包括技术和科学术语)具有本领域技术人员通常所理解的含义,除非另外定义。应注意,这里使用的术语应解释为具有与本说明书的上下文相一致的含义,而不应以理想化或过于刻板的方式来解释。All terms (including technical and scientific terms) used herein have the meaning as commonly understood by one of ordinary skill in the art, unless otherwise defined. It should be noted that terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed 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的系统等)。Where expressions like "at least one of A, B, and C, etc.," are used, they should generally be interpreted in accordance with the meaning of the expression as commonly understood by those skilled in the art (eg, "has A, B, and C") At least one of the "systems" shall include, but not be limited to, systems with A alone, B alone, C alone, A and B, A and C, B and C, and/or A, B, C, etc. ).

在一种技术方案中,客户端与服务端进行交互的过程中,客户端会向服务端发送服务请求,然后服务端对服务请求进行处理,服务端处理完毕后会将响应消息返回至客户端。若服务端未能及时通过同步消息传输通道向客户端返回响应消息,同步消息传输通道会断开连接,导致服务端无法将响应消息返回至客户端,进而造成客户端与服务端交互异常。In a 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, and the server returns a response message to the client after processing. . 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, so that the server cannot return the response message to the client, resulting in abnormal interaction between the client and the server.

本公开的实施例提供了一种请求响应方法,该方法包括:向服务端发送服务请求;对服务端响应服务请求进行监测;响应于监测到服务端响应超时而断开服务端和客户端之间的同步消息传输通道,创建用于重新连接客户端和服务端的异步消息传输通道;以及通过异步消息传输通道,接收来自服务端的针对服务请求的响应消息。本公开的实施例提供的技术方案,可以在同步消息传输通道由于超时而断开后创建异步消息传输通道,从而确保客户端接收到响应消息。An 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; and disconnecting the server and the client in response to monitoring that the server response times out. A synchronous message transmission channel between the client and the server is created to create an asynchronous message transmission channel for reconnecting the client and the server; and a response message for the service request from the server is received through the asynchronous message transmission channel. The technical solutions provided by the embodiments of the present disclosure can create an asynchronous message transmission channel after the synchronous message transmission channel is disconnected due to timeout, so as to ensure that the client receives the response message.

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

如图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 , and 103 , a network 104 and a server 105 . The network 104 is a medium used to provide a communication link 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, and the like.

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

终端设备101、102、103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 101, 102, 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, desktop computers, and the like.

服务器105可以是提供各种服务的服务器,例如对用户利用终端设备101、102、103所浏览的网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的客户端发送的请求等数据进行分析等处理,并将处理结果(例如根据客户端发送的请求生成的响应消息等)反馈给终端设备。The server 105 may be a server that provides various services, such as a background management server (just an example) that provides support for websites browsed by users using the terminal devices 101 , 102 , and 103 . The background management server can analyze and process the received data such as the request sent by the client, and feed back the processing result (for example, a response message generated according to the request sent by the client, etc.) 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 by the embodiment of the present disclosure may generally be executed by the server 105 . Correspondingly, the message processing apparatus provided by the embodiments of the present disclosure may generally be provided in the server 105 . The service request response method provided by the embodiment of the present disclosure may also be executed by a server or server cluster different from the server 105 and capable of communicating with the terminal devices 101 , 102 , 103 and/or the server 105 . Correspondingly, the message processing apparatus provided by the embodiments of the present disclosure may also be provided in a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101 , 102 , 103 and/or the server 105 . Alternatively, the request response method provided by the embodiment of the present disclosure may also be executed by the terminal device 101 , 102 , or 103 , or may also be executed by other terminal device different from the terminal device 101 , 102 , or 103 . Correspondingly, the message processing apparatus provided in the embodiment of the present disclosure may also be provided in the terminal device 101 , 102 , or 103 , or in another terminal device different from the terminal device 101 , 102 , or 103 .

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

应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in FIG. 1 are merely illustrative. There can be any number of terminal devices, networks and servers according to implementation needs.

图2示意性示出了根据本公开实施例的请求响应方法的流程图。FIG. 2 schematically shows a flowchart 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-S240. The request-response method can be executed by the client.

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

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

在操作S220,对服务端响应服务请求进行监测。In operation S220, the server's response 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, the timeout processing function can be used to monitor the time consumed by the client waiting for the server to respond to the service request. Hereinafter, the time consumed by the client waiting for the server to respond to the service request is simply referred to as the waiting time, and the waiting time may represent the time from when the client sends the server request to the current moment. If the waiting time of the client is greater than or equal to the preset timeout, and the client has not received a response message, it means that a timeout event occurs. If the waiting time of the client is less than the preset timeout, and the client receives a response message, it means that a non-timeout event occurs. In practical applications, the client status code can be used to reflect whether a timeout event occurs on the client side. For example, the client's status code can be 504 when a timeout event occurs on the client.

在操作S230,响应于监测到服务端响应超时而断开服务端和客户端之间的同步消息传输通道,创建用于重新连接客户端和服务端的异步消息传输通道。In operation S230, in response to monitoring 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 for reconnecting the client and the server is created.

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

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

在客户端与服务端进行数据交互时,客户端由于网络堵塞等原因而超时断开后,服务端仍会处理客户端的请求。但是由于客户端已经断开,导致针对该请求的响应消息无法通过同步消息传输通道发送至客户端,因此创建异步的消息传输通道来传输响应消息。When the client interacts with the server, after the client is disconnected due to network congestion and 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 solutions provided by the embodiments of the present disclosure, after the synchronous message transmission channel between the client and the server is disconnected due to a 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 Therefore, the server can ensure that the response message is received by the server, and at the same time, the user can be prevented from repeatedly sending the service request 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 operation: in response to monitoring that the synchronization message transmission channel is disconnected, creating a socket of the client. Then, the client's socket is used to send a connection request to the server's socket, so that the server's socket processes the connection request and obtains a connection response. An asynchronous messaging channel is then created in response to receiving a connection response from the server's socket.

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

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

本公开实施例利用套接字实现客户端和服务端之间的通信,可以使客户端和服务端之间较为便捷且快速地重新建立连接。The embodiments of the present disclosure use sockets to implement the communication between the client and the server, so that the connection between the client and the server can be re-established more conveniently and quickly.

在一种示例中,可以监测客户端,并在监测到客户端超时的情况下创建客户端的套接字。在另一种示例中,可以监测服务端,例如监测到服务端产生的中断信息之后创建客户端的套接字。In one example, a client may be monitored and a client's socket created if the client is detected to have timed out. In another example, the server can be monitored, for example, a socket of the client can be created after monitoring the interrupt information generated by the server.

需要说明的是,客户端与服务端进行数据交互的过程中,客户端中断连接后,服务端会继续处理请求,然后在服务端发送响应消息并发现客户端断开后,服务端才会产生中断消息。可以看出,采用监测服务端的方案时,需要等待服务端对请求处理完毕后,再创建客户端的套接字,导致客户端收到响应消息的时间滞后。因此,可以采用监测客户端的方式来确定是否创建客户端的套接字,从而更加及时地创建客户端的套接字,减少客户端通过异步消息传输通道接收响应消息所需的时间。It should be noted that in the process of data interaction between the client and the server, after the client disconnects, the server will continue to process the request, and then the server will send a response message and find that the client is disconnected. interrupt message. It can be seen that when using the solution of monitoring the server, it is necessary to wait for the server to process the request before creating the client's socket, resulting in a time lag for the client to receive the response message. Therefore, the method of monitoring the client can be used to determine whether to create the client's socket, so as to create the client's socket in a more timely manner 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 above-mentioned request response method may further include the following operation: before creating an asynchronous message transmission channel for reconnecting the client and the server, acquiring the running status information of the connection pool, wherein the connection pool stores information about the running status of the connection pool. The service request sent by the client to the server. Then, when the running state information of the connection pool satisfies the preset running conditions, a creation operation is triggered to create an asynchronous message transmission channel.

例如,预设运行条件可以包括第一条件和第二条件中的至少一个。第一条件包括:连接池中存储的请求数量大于或等于第一预设阈值,第一预设阈值可以是100。第二条件包括:连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值,第二预设阈值可以是0.9。For example, the preset operating condition may include at least one of the first condition and the 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, and the first preset threshold 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, and the second preset threshold may be 0.9.

连接池的运行状态信息满足预设运行条件可以表示负载过大无法对服务请求进行及时有效地处理,发生超时事件的风险较高,因此可以创建异步消息传输通道,从而确保客户端接收到来自服务端的响应消息。The running status information of the connection pool satisfies the preset running conditions, which means that the load is too large and the service request cannot be processed in a timely and effective manner. terminal response message.

根据本公开另一实施例,上述请求响应方法还可以包括以下操作:在创建用于重新连接客户端和服务端的异步消息传输通道之后,输出用于提示等待响应信息的提示信息。According to another embodiment of the present disclosure, the above 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 waiting for response information.

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

本公开实施例通过提示信息来提示用户暂时等待,而不是提示用户出现错误,从而提供更好的用户体验。The embodiment of the present disclosure prompts the user to wait temporarily by prompting 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 longer than 1 minute, abnormal prompt information for prompting an exception can also be output, and the user can control the client to resend the request according to the prompt message, so as to obtain the response in time information.

图3示意性示出了根据本公开另一实施例的请求响应方法的流程图。FIG. 3 schematically shows a flowchart 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-S320. The request-response method can be executed by the server.

在操作S310,响应于接收到来自客户端的服务请求,对服务请求进行处理,得到响应消息。In operation S310, in response to receiving the service request from the 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 the asynchronous message transmission channel. The asynchronous message transmission channel is created when the server disconnects the synchronous message transmission channel in response to a timeout, and the asynchronous message transmission channel is used to reconnect the client and the server.

需要说明的是,服务端对请求进行处理后得到响应消息,若未发生超时时间,服务端可以利用同步消息传输通道将响应消息发送至客户端。若发生超时事件,服务端可以利用异步消息传输通道将响应消息发送至客户端。It should be noted that the server obtains a response message after processing the request. If the timeout period does not occur, 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 a response message to the client.

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

根据本公开另一实施例,上述请求响应方法还可以包括以下操作:在通过异步消息传输通道向客户端发送响应消息之前,创建服务端的套接字。然后在服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对连接请求进行处理,得到连接响应。向客户端的套接字发送连接响应,以便创建异步消息传输通道。客户端的套接字是客户端在监测到服务端响应超时而断开同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the above request-response method may further include the following operation: before sending a response message to the client through an asynchronous message transmission channel, creating a socket of the server. Then, 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. Send a connect response to the client's socket to create an asynchronous messaging channel. The client's socket is created when the client disconnects the synchronous message transmission channel after monitoring the server's response timeout.

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

本公开实施例利用套接字实现客户端和服务端之间的通信,可以使客户端和服务端之间较为便捷且快速地重新建立连接。The embodiments of the present disclosure use sockets to implement the communication between the client and the server, so that the connection between the client and the server can be re-established more conveniently and quickly.

根据本公开另一实施例,上述响应于监测到客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向客户端发送响应消息的操作,可以包括以下操作:响应于监测到指示同步消息传输通道断开的中断消息,根据中断消息,从多个候选响应消息中确定针对服务请求的响应消息。然后通过异步消息传输通道向客户端发送响应消息。According to another embodiment of the present disclosure, the above operation of sending 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 may include the following operations: in response to monitoring To the interrupt message indicating the disconnection of the synchronization message transmission channel, a response message for the service request is determined from a plurality of candidate response messages according to the interrupt message. The response message is then sent to the client over an asynchronous messaging channel.

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

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

以下以一个具体实施例,对本公开实施例提供的请求响应方法进行说明。本实施例涉及客户端和服务端。The request response method provided by the embodiment of the present disclosure will be 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 the synchronization message transmission channel is disconnected. If not, the client can wait for a response message; if so, the client creates the client's socket, and then uses the client's socket to send a connection request to the server's socket.

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

由于客户端的套接字向服务端的套接字发送连接请求,因此服务端的套接字监测到来自客户端的套接字的连接请求之后,服务端可以处理连接请求,得到连接响应。然后服务端的套接字向客户端的套接字发送连接响应。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 get a connection response. The server's socket then 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示意性示出了根据本公开实施例的请求响应装置的框图。FIG. 4 schematically shows a block diagram of a request response apparatus according to an embodiment of the present disclosure.

如图4所示,请求响应装置400可以包括第一发送模块410、监测模块420、第一创建模块430以及接收模块440。As shown in FIG. 4 , the request response apparatus 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 configured to send a service request to the server.

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

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

接收模块440用于通过异步消息传输通道,接收来自服务端的针对服务请求的响应消息。The receiving module 440 is configured to receive the response message for 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 configured to create a client socket in response to detecting that the synchronization message transmission channel is disconnected. The first sending submodule is used to send a connection request to the socket of the server by using the socket of the client, so that the socket of the server can obtain a connection response after processing the connection request. The second creation submodule is configured 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 above-mentioned request response apparatus further includes an acquisition module and a trigger module. The obtaining module is used for obtaining the running state information of the connection pool before creating the 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 triggering module is used to trigger a creation operation to create an asynchronous message transmission channel when the running state information of the connection pool satisfies 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 the 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 the second Preset threshold.

根据本公开另一实施例,监测模块包括监测子模块,用于利用超时处理函数对客户端等待服务端响应服务请求消耗的时长进行监测。According to another embodiment of the present disclosure, the monitoring module includes a monitoring sub-module 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 above-mentioned request response apparatus further includes a prompt module for outputting prompt information for prompting waiting for response information after creating an asynchronous message transmission channel for reconnecting the client and the server.

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

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

第一处理模块510用于响应于接收到来自客户端的服务请求,对服务请求进行处理,得到响应消息。The first processing module 510 is configured to process 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 configured 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 disconnects the synchronous message transmission channel in response to a timeout, and the asynchronous message transmission channel is used to reconnect the client and the server.

根据本公开另一实施例,上述请求响应装置还包括第二创建模块、第二处理模块和第三发送模块。第二创建模块用于在通过异步消息传输通道向客户端发送响应消息之前,创建服务端的套接字。第二处理模块用于在服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对连接请求进行处理,得到连接响应。第三发送模块用于向客户端的套接字发送连接响应,以便创建异步消息传输通道。客户端的套接字是客户端在监测到服务端响应超时而断开同步消息传输通道的情况下创建的。According to another embodiment of the present disclosure, the above-mentioned request response apparatus 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 configured to process the connection request to obtain a connection response when the socket of the server monitors the connection request from the socket of the client. The third sending module is used for sending a connection response to the socket of the client, so as to create an asynchronous message transmission channel. The client's socket is created when the client disconnects the synchronous message transmission channel after monitoring the server's response timeout.

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

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

根据本公开的实施例的模块和子模块中的任意多个、或其中任意多个的至少部分功能可以在一个模块中实现。根据本公开实施例的模块和子模块中的任意一个或多个可以被拆分成多个模块来实现。根据本公开实施例的模块和子模块中的任意一个或多个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式的硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,根据本公开实施例的模块和子模块中的一个或多个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。Any number of, or at least part of the functionality of, any of the modules and sub-modules according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules and sub-modules according to the embodiments of the present disclosure may be split into multiple modules for implementation. Any one or more of the modules and sub-modules according to embodiments of the present disclosure may be implemented, at least in part, as hardware circuits, such as Field Programmable Gate Arrays (FPGAs), Programmable Logic Arrays (PLAs), System-on-Chip, A system, a system-on-package, an application specific integrated circuit (ASIC), or any other reasonable hardware or firmware implementation that can integrate or package a circuit, or in any one of software, hardware, and firmware implementations or any appropriate combination of any of them. Alternatively, one or more of the modules and sub-modules according to embodiments of the present disclosure may be implemented at least in part as computer program modules that, when executed, may perform corresponding functions.

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

图6示意性示出了根据本公开实施例的适于实现上文描述的方法和装置的电子设备的框图。图6示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Figure 6 schematically shows a block diagram of an electronic device suitable for implementing the methods 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 impose any limitation on the function and scope of use of the embodiments of the present disclosure.

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

在RAM 603中,存储有电子设备600操作所需的各种程序和数据。处理器601、ROM602以及RAM 603通过总线604彼此相连。处理器601通过执行ROM 602和/或RAM 603中的程序来执行根据本公开实施例的方法流程的各种操作。需要注意,所述程序也可以存储在除ROM 602和RAM 603以外的一个或多个存储器中。处理器601也可以通过执行存储在所述一个或多个存储器中的程序来执行根据本公开实施例的方法流程的各种操作。In the RAM 603, various programs and data necessary for the operation of the electronic device 600 are stored. The processor 601 , the ROM 602 and the RAM 603 are connected to each other through a bus 604 . The processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 602 and/or the RAM 603 . Note that the program may also be stored in one or more memories other than the ROM 602 and the RAM 603 . The processor 601 may also perform various operations of the method flow according to the embodiments of the present disclosure by executing programs 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 also include an input/output (I/O) interface 605 which is also connected to the bus 604 . Electronic device 600 may also include one or more of the following components connected to I/O interface 605: input portion 606 including a keyboard, mouse, etc.; including components such as a cathode ray tube (CRT), liquid crystal display (LCD), etc., and An output section 607 of speakers and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 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 mounted on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 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 may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the method illustrated in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 609 and/or installed from the removable medium 611 . When the computer program is executed by the processor 601, the above-described functions defined in the system of the embodiment of the present disclosure are performed. According to embodiments of the present disclosure, the above-described systems, apparatuses, apparatuses, modules, units, etc. can be implemented by computer program modules.

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

根据本公开的实施例,计算机可读存储介质可以是非易失性的计算机可读存储介质。例如可以包括但不限于:便携式计算机磁盘、硬盘、随机访问存储器(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. Examples may include, but are not limited to, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), portable compact disk read only memory (CD- ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

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

附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented in special purpose hardware-based systems that perform the specified functions or operations, or can be implemented using A combination of dedicated hardware and computer instructions is implemented.

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

以上对本公开的实施例进行了描述。但是,这些实施例仅仅是为了说明的目的,而并非为了限制本公开的范围。尽管在以上分别描述了各实施例,但是这并不意味着各个实施例中的措施不能有利地结合使用。本公开的范围由所附权利要求及其等同物限定。不脱离本公开的范围,本领域技术人员可以做出多种替代和修改,这些替代和修改都应落在本公开的范围之内。Embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only, and are not intended to limit the scope of the present disclosure. Although the various 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 appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art can make various substitutions and modifications, and these substitutions and modifications should all fall within the scope of the present disclosure.

Claims (14)

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 monitoring that the server response times 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; and 通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息。A response message for the service request from the server is received through the asynchronous message transmission channel. 2.根据权利要求1所述的方法,其中,所述响应于监测到所述服务端响应超时而断开所述服务端和客户端之间的同步消息传输通道,创建用于重新连接所述客户端和所述服务端的异步消息传输通道包括:2. The method according to claim 1, wherein, in response to monitoring that the server responds to a timeout, the synchronous message transmission channel between the server and the client is disconnected, and a synchronous message transmission channel is created for reconnecting the The asynchronous message transmission channel between the client and the server includes: 响应于监测到所述同步消息传输通道已断开,创建所述客户端的套接字;In response to monitoring that the synchronization message transmission channel has been disconnected, creating a socket for the client; 利用所述客户端的套接字向所述服务端的套接字发送连接请求,以便所述服务端的套接字对所述连接请求进行处理后得到连接响应;Use the socket of the client to send a connection request to the socket of the server, so that the socket of the server can obtain a connection response after processing the connection request; 响应于接收到来自所述服务端的套接字的连接响应,创建所述异步消息传输通道。The asynchronous messaging channel is created in response to receiving a connection response from the server's socket. 3.根据权利要求1所述的方法,还包括:3. The method of claim 1, further comprising: 在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之前,获取连接池的运行状态信息,其中,所述连接池中存储有所述客户端向所述服务端发送的服务请求;以及Before creating an asynchronous message transmission channel for reconnecting the client and the server, obtain running status information of a connection pool, where the connection pool stores the services sent by the client to the server request; and 在所述连接池的运行状态信息满足预设运行条件的情况下,触发创建操作,以创建所述异步消息传输通道。When the running state information of the connection pool satisfies a preset running condition, a creation operation is triggered to create the asynchronous message transmission channel. 4.根据权利要求3所述的方法,其中,所述预设运行条件包括所述连接池中存储的请求数量大于或等于第一预设阈值;以及/或者所述连接池中存储的请求数量与最大请求数量的比值大于或等于第二预设阈值。4. The method according to claim 3, wherein the preset operating condition comprises that the number of requests stored in the connection pool is greater than or equal to a first preset threshold; and/or the number of requests stored in the connection pool The ratio to the maximum number of requests is greater than or equal to the second preset threshold. 5.根据权利要求1所述的方法,其中,所述对所述服务端响应所述服务请求进行监测包括:5. The method according to claim 1, wherein the monitoring the response of the server to the service request comprises: 利用超时处理函数对所述客户端等待所述服务端响应所述服务请求消耗的时长进行监测。The time consumed by the client waiting for the server to respond to the service request is monitored by using a timeout processing function. 6.根据权利要求1所述的方法,还包括:6. The method of claim 1, further comprising: 在创建用于重新连接所述客户端和所述服务端的异步消息传输通道之后,输出用于提示等待所述响应信息的提示信息。After the asynchronous message transmission channel for reconnecting the client and the server is created, prompt information for prompting waiting for the response information is output. 7.一种请求响应方法,包括:7. A request-response method, comprising: 响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息;In response to receiving the service request from the client, processing the service request to obtain a response message; 响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息;以及In response to detecting that the synchronous message transmission channel between the client and the server is disconnected, send the response message to the client through an asynchronous message transmission channel; and 其中,所述异步消息传输通道是在所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。The asynchronous message transmission channel is created when the server disconnects the synchronous message transmission channel in response to a timeout, and the asynchronous message transmission channel is used to reconnect the client and the server . 8.根据权利要求7所述的方法,还包括:在通过异步消息传输通道向所述客户端发送所述响应消息之前,8. The method of claim 7, further comprising: before sending the response message to the client over an asynchronous message transfer channel, 创建所述服务端的套接字;Create the socket of the server; 在所述服务端的套接字监测到来自客户端的套接字的连接请求的情况下,对所述连接请求进行处理,得到连接响应;In the case that the socket of the server monitors the connection request from the socket of the client, the connection request is processed to obtain a connection response; 向所述客户端的套接字发送所述连接响应,以便创建所述异步消息传输通道;sending the connection response to the client's socket to create the asynchronous messaging channel; 其中,所述客户端的套接字是所述客户端在监测到所述服务端响应超时而断开所述同步消息传输通道的情况下创建的。The socket of the client is created when the client detects that the server disconnects the synchronization message transmission channel in response to a timeout. 9.根据权利要求7所述的方法,所述响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息包括:9. The method according to claim 7, wherein 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 comprises: : 响应于监测到指示所述同步消息传输通道断开的中断消息,根据所述中断消息,从多个候选响应消息中确定针对所述服务请求的所述响应消息;以及in response to detecting an interruption 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 based on the interruption message; and 通过所述异步消息传输通道向所述客户端发送所述响应消息。The response message is sent to the client through the asynchronous message transmission channel. 10.一种请求响应装置,包括:10. A request response device, comprising: 第一发送模块,用于向服务端发送服务请求;a first sending module, configured to send a service request to the server; 监测模块,用于对所述服务端响应所述服务请求进行监测;a monitoring module, configured 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 responds to a timeout, and create an asynchronous connection for reconnecting the client and the server. message transmission channels; and 接收模块,用于通过所述异步消息传输通道,接收来自所述服务端的针对所述服务请求的响应消息。A receiving module, configured to receive a response message for the service request from the server through the asynchronous message transmission channel. 11.一种请求响应装置,包括:11. A request response device, comprising: 第一处理模块,用于响应于接收到来自客户端的服务请求,对所述服务请求进行处理,得到响应消息;以及a first processing module, configured to process the service request in response to receiving the service request from the client to obtain a response message; and 第二发送模块,用于响应于监测到所述客户端和服务端之间的同步消息传输通道断开,通过异步消息传输通道向所述客户端发送所述响应消息;a second sending module, configured to send the 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; 其中,所述异步消息传输通道是在所述服务端响应超时而断开所述同步消息传输通道的情况下创建的,所述异步消息传输通道用于重新连接所述客户端和所述服务端。The asynchronous message transmission channel is created when the server disconnects the synchronous message transmission channel in response to a timeout, and the asynchronous message transmission channel is used to reconnect the client and the server . 12.一种电子设备,包括:12. An electronic device comprising: 一个或多个处理器;one or more processors; 存储器,用于存储一个或多个程序,memory for storing one or more programs, 其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现权利要求1至9中任一项所述的方法。Wherein, the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1 to 9. 13.一种计算机可读存储介质,其上存储有可执行指令,该指令被处理器执行时使处理器实现权利要求1至9中任一项所述的方法。13. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to implement the method of any one of claims 1 to 9. 14.一种计算机程序产品,包括计算机可执行指令,所述指令在被执行时用于实现权利要求1至9中任一项所述的方法。14. A computer program product comprising computer executable instructions which, when executed, are used to implement the method of any of claims 1 to 9.
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 true CN115103005A (en) 2022-09-23
CN115103005B 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)

Cited By (1)

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

Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030033520A1 (en) * 2000-10-10 2003-02-13 Christopher Peiffer HTTP multiplexor/demultiplexor system for use in secure transactions
US20050257258A1 (en) * 2004-05-14 2005-11-17 International Business Machines Corporation Information processing apparatus, information system, proxy processing method, and program and recording medium therefor
US20060271681A1 (en) * 2005-05-31 2006-11-30 Microsoft Corporation Re-establishing a connection for an application layer via a service layer
US7562147B1 (en) * 2000-10-02 2009-07-14 Microsoft Corporation Bi-directional HTTP-based reliable messaging protocol and system utilizing same
CN103312558A (en) * 2013-05-15 2013-09-18 武汉长江通信产业集团股份有限公司 Network connection availability monitoring method and system in computer client server 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
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
CN108833950A (en) * 2018-06-29 2018-11-16 武汉斗鱼网络科技有限公司 A method, server, system and storage medium for sending barrage messages
CN108989404A (en) * 2018-06-29 2018-12-11 武汉斗鱼网络科技有限公司 A kind of barrage message issuing method, server, system and storage medium
CN111385287A (en) * 2020-02-20 2020-07-07 视联动力信息技术股份有限公司 Network reconnection method and device for service system
CN111953678A (en) * 2020-08-11 2020-11-17 福州职业技术学院 Method and system for verifying DNS request security
CN112134907A (en) * 2019-06-24 2020-12-25 北京京东尚科信息技术有限公司 Message processing method, device and device
CN112181652A (en) * 2020-09-25 2021-01-05 北京天融信网络安全技术有限公司 Method and device for adjusting capacity of connection pool, storage medium and electronic equipment
US20210218693A1 (en) * 2020-05-27 2021-07-15 Beijing Baidu Netcom Science And Technology Co., Ltd. Method for transmitting live message, apparatus, electronic device and medium
CN113986501A (en) * 2021-10-28 2022-01-28 西安热工研究院有限公司 Real-time database API (application program interface) uninterrupted calling method, system, storage medium and server

Patent Citations (18)

* 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
US20030033520A1 (en) * 2000-10-10 2003-02-13 Christopher Peiffer HTTP multiplexor/demultiplexor system for use in secure transactions
US20050257258A1 (en) * 2004-05-14 2005-11-17 International Business Machines Corporation Information processing apparatus, information system, proxy processing method, and program and recording medium therefor
CN1738305A (en) * 2004-05-14 2006-02-22 国际商业机器公司 Information processing apparatus, information system, proxy processing method
US20060271681A1 (en) * 2005-05-31 2006-11-30 Microsoft Corporation Re-establishing a connection for an application layer via a service layer
CN107071826A (en) * 2011-03-17 2017-08-18 华为技术有限公司 The method and apparatus of transmitting data resources
CN103312558A (en) * 2013-05-15 2013-09-18 武汉长江通信产业集团股份有限公司 Network connection availability monitoring method and system in computer client server 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
CN107147663A (en) * 2017-06-02 2017-09-08 广东暨通信息发展有限公司 Synchronous communication method and system of a computer cluster system
CN108833950A (en) * 2018-06-29 2018-11-16 武汉斗鱼网络科技有限公司 A method, server, system and storage medium for sending barrage messages
CN108989404A (en) * 2018-06-29 2018-12-11 武汉斗鱼网络科技有限公司 A kind of barrage message issuing method, server, system and storage medium
CN112134907A (en) * 2019-06-24 2020-12-25 北京京东尚科信息技术有限公司 Message processing method, device and device
CN111385287A (en) * 2020-02-20 2020-07-07 视联动力信息技术股份有限公司 Network reconnection method and device for service system
US20210218693A1 (en) * 2020-05-27 2021-07-15 Beijing Baidu Netcom Science And Technology Co., Ltd. Method for transmitting live message, apparatus, electronic device and medium
CN111953678A (en) * 2020-08-11 2020-11-17 福州职业技术学院 Method and system for verifying DNS request security
CN112181652A (en) * 2020-09-25 2021-01-05 北京天融信网络安全技术有限公司 Method and device for adjusting capacity of connection pool, storage medium and electronic equipment
CN113986501A (en) * 2021-10-28 2022-01-28 西安热工研究院有限公司 Real-time database API (application program interface) uninterrupted calling method, system, storage medium and server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
胡鹏;夏扬;曲爱妍;: "一种针对LDAP客户端与服务器通信的改进方案", 舰船电子工程, no. 01 *

Cited By (1)

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

Also Published As

Publication number Publication date
CN115103005B (en) 2024-08-16

Similar Documents

Publication Publication Date Title
WO2021237433A1 (en) Message pushing method and apparatus, and electronic device and computer-readable medium
CN108616429B (en) reconnection method and device for push 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
WO2021134928A1 (en) Method, device, system and apparatus for p2p network-based data transmission, and medium
CN107645517B (en) Data pushing method and device
CN102739411A (en) provide certification services
CN112953769B (en) Data transmission method, device, computer system and readable storage medium
GB2518739A (en) Custom Correlation of a Distributed Business Transaction
CN113114535A (en) Network fault detection method and device and electronic equipment
WO2022083379A1 (en) Connection processing method and apparatus, electronic device, and computer-readable storage medium
CN109976919A (en) A kind of transmission method and device of message request
CN115103005A (en) Request response method and device, electronic equipment and storage medium
CN116260747A (en) Monitoring method, device and electronic equipment of terminal testing equipment
CN114257632B (en) Method and device for reconnecting broken wire, electronic equipment and readable storage medium
CN113542324A (en) Message pushing method and device
CN116074367B (en) Data processing method, device, electronic device and storage medium
CN111416851A (en) Method for session synchronization among multiple load balancers and load balancer
CN108289165B (en) Method and device for realizing camera control based on mobile phone and terminal equipment
CN114172946B (en) Request result sending method, device, electronic device and computer readable medium
CN117596288A (en) Message transmission method and device, electronic equipment and storage medium
CN115714805A (en) Cross-platform communication connection method and system and electronic equipment
CN111490997B (en) Task processing method, agent system, service system and electronic device
CN114745276A (en) Switch bandwidth adjusting method and device, electronic equipment and computer readable medium
CN115203334B (en) Data processing method, device, electronic 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