Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The network information acquisition method provided by the application can be applied to the application environment shown in fig. 1. The information acquisition method comprises aninformation acquisition end 102, anintermediate server 104 and atarget server 106, wherein the target server is a server providing information required by theinformation acquisition end 102, theinformation acquisition end 102 can establish target long connection with theintermediate server 104, theintermediate server 104 establishes service connection with thetarget server 106, thetarget server 106 can send the information required by theinformation acquisition end 102 to theintermediate server 104 through the service connection, and theintermediate server 104 pushes the information required by the information acquisition end to theinformation acquisition end 102 through the target long connection. In addition, theinformation obtaining end 102 may also establish a short connection with thetarget server 104, and obtain the required information from the target server through the short connection.
With the development of services, there are more demands for communication efficiency and server-side push. The network information acquisition method provided by the embodiment of the application can be applied to various scenes needing instant message acquisition, such as instant chat live broadcast, stock or game scenes. For example, a general target server may not have the capability of performing webSocket connection, so that when it is determined that the information obtaining end has corresponding target information, the target information cannot be directly pushed to the client through the target server, and the client is required to continuously send a query request to the server to obtain the target information. In order to improve the efficiency of information acquisition, although the target server may be upgraded to support the WebSocket connection to support the capability of background push, if the existing target server is modified to support the WebSocket connection, the modification cost is huge, because the service of the existing target server may be already very complicated, and the modification process inevitably causes the suspension of the existing service and the modification of the related interface. Meanwhile, the modification has great risks, such as unverified WebSocket compatibility, unverified server concurrency performance, persuasive of extra learning cost brought by accepting the mode conversion by all background development, and the like. By the method provided by the embodiment of the application, the intermediate server is built, the target long connection can be built between the intermediate server and the information acquisition end under the condition that the target server is not required to be modified and the connection pool is not required to be managed, and therefore the efficiency of the information acquisition end for acquiring information from the target server can be improved. And the established long connection is transparent to the target server, so that the information of the target server can be timely pushed to the information acquisition end even under the condition that the target server does not even feel the existence of the stations in the WebSocket.
Theinformation obtaining end 102 may be a terminal, such as but not limited to various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and theintermediate server 104 and thetarget server 106 may be servers, which may be implemented by independent servers or a server cluster formed by multiple servers.
In some embodiments, as shown in fig. 2, a network information acquisition system is provided, which includes anintermediate server 104 and atarget server 106.
And theintermediate server 104 is used for establishing the target long connection with the information acquisition end.
The information obtaining end is an end that needs to obtain information, and may be a mobile phone, for example. The information acquisition end can be provided with a client, and the information to be acquired by the client is set according to the requirement. For example, it may be a get session message or a get video.
The long connection (persistent connection) refers to a manner of not disconnecting after connection and completing data transmission once, and continuing to maintain the transmission channel until disconnection conditions are met, that is, one request can correspond to multiple responses, and multiple data transmissions can be performed through the long connection. The long connection may be, for example, a WebSocket connection. The WebSocket is a network transmission protocol, can provide a full-duplex communication mode, and allows a server to actively push data to a client. Through long connection, the pushed information can be obtained in time. For example, in a group chat, if a session terminal establishes a long connection with a session server, a session message sent to the session server by the session terminal corresponding to another user in the group chat and pushed by the session server may be received through the long connection.
The target server is the one that provides the information to be acquired by the information acquisition side. For example, when the information obtaining end needs to obtain the session message, the target service end is a session server, and is used for providing the session message. Namely, the target server is the target server which is originally connected when the information acquisition end acquires the information. By the network information acquisition system provided by the embodiment of the application, the information acquisition end can establish target long connection with the intermediate server end, and acquire information from the target server end through the intermediate server end.
Specifically, when the information obtaining end needs to obtain information, for example, when an operation of obtaining information by a user is received, a long connection establishment request for establishing a long connection may be sent to the intermediate server. And the intermediate server responds to the long connection establishment request and establishes a long connection with the information acquisition terminal, wherein the long connection is called a target long connection.
In some embodiments, the step of establishing the long connection between the intermediate server and the information obtaining end includes: receiving a long connection establishment request sent by an information acquisition end; responding to the long connection establishment request, and acquiring the number of long connections corresponding to the established long connections; and when the number of the long connections is less than the threshold value of the number of the connections, establishing target long connections with the information acquisition terminal.
Wherein the long connection establishment request is for requesting establishment of a long connection. The long connection establishment request may carry a connection type identifier corresponding to the long connection, which is used to identify that the request is for establishing the long connection, for example, the long connection establishment request may carry a protocol identifier of a WebSocket protocol, which indicates that the long connection establishment request is used to request to establish the WebSocket connection.
The number of long connections is the number of long connections that the intermediate server has established. And the intermediate service end counts the established long connections in the local end to obtain the number of the long connections. The threshold of the number of connections may be preset and may be determined according to the load capacity of the intermediate server, for example, may be 5000. The threshold of the number of connections may also be determined according to the current operation performance of the intermediate server. The operation performance and the connection quantity threshold value form a positive correlation relationship, and the better the operation performance is, the larger the connection quantity value is. For example, the current read-write speed of the intermediate server may be determined, and the current connection number threshold may be determined based on the correspondence between the read-write speed and the connection number threshold. The reading and writing speed and the connection quantity value form a positive correlation relationship, namely the connection quantity value is larger when the reading and writing speed is higher, so that the number of the long connections which can be established is larger when the reading and writing speed is higher at the server.
Specifically, when the number of long connections is smaller than the threshold of the number of connections, the intermediate server establishes a target long connection with the information acquisition end. When the number of the long connections is larger than the threshold value of the number of the connections, the intermediate server refuses to establish the long connections with the information acquisition end, so that the load of the intermediate server is not too high, and the processing capacity of the intermediate server is ensured.
In some embodiments, when the number of long connections is greater than the threshold of the number of connections, connection rejection information is sent to the information acquisition end, so that when the information acquisition end receives the connection rejection information, a connection address corresponding to the target server end is acquired, and a short connection is established with the target server end.
The connection refusing information is used for indicating that the intermediate server refuses to establish long connection with the information acquisition terminal. The connection address corresponding to the target server is used for connecting with the target server, and may be, for example, a domain name corresponding to the target server.
Specifically, the information obtaining end may first attempt to establish a long connection with the intermediate server, and when the long connection is successfully established, communicate with the intermediate server through the established target long connection, and obtain information sent from the target server to the intermediate server through the target long connection. When the long connection is failed to be established, the information acquisition end can establish short connection with the target server based on the connection address of the target server, and acquire required information from the target server through the short connection. It can be understood that, at this time, since the information obtaining end establishes a short connection with the target server, the connection will be broken after one-time information transmission, if the information obtaining end needs to continuously obtain information from the target server, after the connection is broken, the information obtaining end may automatically detect whether the information to be obtained by the information obtaining instruction is information that is updated many times, and if so, may automatically send a long connection establishing request for establishing a long connection to the intermediate server every preset time length, so as to try to establish a long connection with the intermediate server, and obtain information through the long connection, reduce the number of times of sending the information obtaining request to the target server and improve the timeliness of obtaining information.
In some embodiments, the information obtaining end may further determine the number of times of sending the long connection establishment request to the intermediate server, and when the number of times is greater than the preset number of times, the information obtaining end still fails to successfully connect, the information obtaining end stops automatically sending the long connection establishment request to the intermediate server, and sends a request of establishing a short connection to the target server every preset time interval by using a connection policy of establishing a short connection with the target server, and obtains an updated message from the target server through the short connection, thereby reducing a situation that the information obtaining end cannot obtain the updated message due to an overload of the intermediate server and a failure of establishing the long connection, and improving information obtaining efficiency.
In some embodiments, the information obtaining side may store a connection address of the target server and an address of the intermediate server. The information acquisition end can try to establish long connection with the intermediate server based on the address of the intermediate server. And when the long connection is successfully established, acquiring the information of the target server based on the long connection. If the long connection is failed to be established, the information acquisition end can establish short connection with the target server based on the stored connection address of the target server.
In some embodiments, the intermediate server may also carry the connection address of the target server in the connection rejection information, and instruct the information server to establish a short connection with the target server, so that the information obtaining end does not need to store the connection address of the target server, and may also establish a short connection with the target server.
In some embodiments, the information obtaining end may carry a randomly generated character string set for verification in sending the long connection establishment request, where the character string set includes at least one verification character string, and may include, for example, 3 verification character strings. A check string includes a plurality of characters. The intermediate server side can process the check character strings, splices characters obtained by processing each check character string, performs hash calculation on the spliced character strings to obtain hash values, and returns the hash values to the information acquisition side. The information acquisition end can process the character strings based on the same processing mode to obtain a hash value, the information acquisition end compares the hash value obtained by calculation of the information acquisition end with the hash value returned by the intermediate server end, and if the comparison is consistent, the long connection between the intermediate server end and the information acquisition end is established. The processing mode is preset, and the information acquisition end and the intermediate server end store the processing mode in advance. Therefore, the information acquisition end can confirm the authenticity of the intermediate server end to be established by the intermediate acquisition end, and the safety of establishing the long connection is ensured. The processing method may be, for example, extracting a character of a numeric type from the check character string, connecting the extracted characters of the numeric type together to form a connected numeric character string, converting the connected numeric character string into an integer number, dividing the integer number by a specific numeric value, where the numeric value of the characteristic may be the number of blank spaces in the check character string, converting the obtained quotient into an integer value, and converting the integer value into a byte array. During splicing, the byte arrays corresponding to each check character string are spliced, and hash calculation is performed on the spliced byte arrays to obtain hash values.
And theintermediate server 104 is configured to receive the information acquisition request sent by the information acquisition end through the long connection, and send information request data in the information acquisition request to the target server through the service connection in response to the information acquisition request.
The information obtaining request is used for requesting to obtain information, such as a request for obtaining an updated session message. The information request data is data for relating to requested data, and the required information can be acquired from the information request data. For example, may include a session user identification and may also include the type of data requested. For example, assuming that the information obtaining request is a request for obtaining an updated session message, the information request data includes an instant messaging identifier of a session user in the information obtaining end and a message type identifier corresponding to the session message, which indicates that the request is for obtaining the session message corresponding to the session user. For another example, if the information acquisition request is a request for acquiring interactive information in a game, the information request data includes an account corresponding to the information acquisition terminal and a name of the game currently in progress.
The service connection refers to a connection for providing an information service. The service connection is established by using the original connection mode when the target server provides the information service, so that the information push of the information acquisition end can be realized under the condition that the connection mode of the target server is not required to be improved. For example, when the target server side provides the information service, the short connection mode is supported, and then the service connection is the short connection. The short connection is opposite to the long connection, and the short connection is a disconnection mode after one-time data transmission is completed, namely, one-time response corresponds to one-time request, and when one-time response is completed, the connection is disconnected. The service connection may be, for example, an http (Hypertext Transfer Protocol) based service connection. http is a network transport protocol, and is a standard for requests and responses between a client and a server. The "http://" at the beginning of the website indicates that the http protocol is used.
Specifically, the intermediate server may receive an information acquisition request sent by the information acquisition end through the established target long connection, and after receiving the information acquisition request, may request to establish a service connection with the target server, and then send information request data in the information acquisition request to the target server through the service connection established with the target server. When the information request data is successfully sent, if the short connection is established with the target server, after receiving the primary response information of the target server responding to the information request data, the intermediate server and the target server are disconnected with each other.
Thetarget server 106 is used for sending the target information to the intermediate server through service connection when the information request data is determined to have the corresponding target information;
the target information is response information corresponding to the information request data. Upon receiving the information request data, the target server may send target information to the intermediate server based on the service connection that sent the information request data. The intermediate server side can also start a connection service, such as a short connection service, when information requested by the information request data is updated, the target server side can request the connection service and establish service connection with the intermediate server side again, so that updated target information can be sent to the intermediate server side through the newly established service connection, and the intermediate server side can push the target information to the information acquisition side based on the target long connection established with the information acquisition side. The target information may be continuously updated, for example, for a session, the obtained target information is a newly sent session message. For the game, if the game state is changed due to the progress of the game, the acquired updated target message is the new game state.
Specifically, taking the session as an example, when the target server receives the information request data for the first time, the target server may send the target information to the intermediate server through the established service connection. And when the service connection is short connection, the target server side and the intermediate server side are disconnected from the established service connection after the target information is sent once. The long connection established between the intermediate server and the information acquisition end is continuously maintained, the session message is updated along with the progress of the session, the target server can detect the information corresponding to the information request data, when the target server detects that the updated session message exists, the target server requests to establish the service connection with the intermediate server again, the updated target session message is sent to the intermediate server through the newly established service connection, and the long connection established between the intermediate server and the information acquisition end is continuously maintained, so that the intermediate server can actively push the updated target information to the information acquisition end through the continuously maintained target long connection.
And theintermediate server 104 is configured to push the target information to the information obtaining end through the target long connection.
Specifically, when the intermediate server receives the target information, the update message is actively pushed to the information acquisition end through the target long connection established in advance, so that the information acquisition end can receive the update message in time. Namely, the information can be continuously transmitted through the target long connection established between the intermediate server and the information acquisition end.
In some embodiments, sending the information request data in the information acquisition request to the target server through the service connection in response to the information acquisition request includes: responding to the information acquisition request, and sending information request data in the information acquisition request and a terminal identifier corresponding to the information acquisition terminal to a target server through service connection; when the information request data is determined to have the corresponding target information, the sending the target information to the intermediate server through the service connection comprises the following steps: when the information request data is determined to have the corresponding target information, the target information and the corresponding terminal identification are sent to the intermediate server through service connection; the pushing of the target information to the information acquisition end through the target long connection comprises the following steps: and pushing target information to an information acquisition end corresponding to the terminal identification through the target long connection.
The terminal identifier is used to identify the identity of the terminal, and may be, for example, an openID or sessionID corresponding to the terminal, where the openID is a character string used by a platform to uniquely identify a user. The session ID is an identification of the created session.
For example, when receiving an information acquisition request, the intermediate server may send an openID or sessionID corresponding to the terminal to the target server through an http request, and when receiving the openID or sessionID, the server monitors information corresponding to information request data, and once information corresponding to the information request data is updated, sends new information to the intermediate server through the http request. In the embodiment of the application, the information request data in the information acquisition request and the terminal identification corresponding to the information acquisition terminal are simultaneously sent to the target server, so that when the intermediate server is connected with a plurality of information acquisition terminals, the target information sent by the target server can be determined to correspond to which information acquisition terminal, and the accuracy of message pushing is ensured.
For example, the intermediate server may send the identity and the information request data corresponding to the information obtaining end to the server, so that the target server may store a corresponding relationship among the identity, the information request data, and the identity of the intermediate server, when the target server determines that there is data required to be obtained by the information obtaining request, establish service connection with the intermediate server again according to the identity of the intermediate server, and send the identity and the corresponding update message corresponding to the information obtaining end to the intermediate server through the service connection. And when the transmission is successful, the target server and the intermediate server are disconnected from service connection. And the intermediate server receives the identity and the update message, determines an information acquisition end which needs to actively push information based on the identity, and pushes the target information to the information acquisition end.
In some embodiments, the intermediary server is further configured to: determining a connection identifier corresponding to the target long connection, and establishing a corresponding relation between the connection identifier and the terminal identifier; the pushing of the target information to the information acquisition end corresponding to the terminal identification through the target long connection comprises the following steps: and determining a connection identifier according to the terminal identifier and the corresponding relation, and pushing target information to the information acquisition end through the target long connection corresponding to the connection identifier.
Specifically, the intermediate server may establish a corresponding relationship between a connection identifier of the target long connection and the terminal identifier after establishing the target long connection, so that when target information sent by the target server is received, the long connection corresponding to the target information may be accurately determined, and active push of information is performed based on the long connection.
In some embodiments, the information obtaining end and the intermediate server end may disconnect the target long connection when it is determined that the information corresponding to the information obtaining request has been completely obtained. For example, when the game is over, the target long connection is disconnected.
In the network information acquisition system, the information acquisition end establishes the target long connection with the intermediate server end, the intermediate server end receives the information acquisition request sent by the target long connection, and then sends the information request data to the target server end by the service connection, so that the target server end can send the target information corresponding to the information request data by the service connection, and meanwhile, the intermediate server end can actively push the information to the information acquisition end quickly by the established target long connection, the times of sending the information acquisition request by the information acquisition end can be reduced, and the information acquisition efficiency is improved.
As shown in fig. 3, in one embodiment, a network information acquisition method is provided. The embodiment is mainly illustrated by applying the method to theinformation obtaining terminal 102 in fig. 1.
Step S302, responding to the information acquisition instruction, and establishing target long connection with the intermediate server.
The information obtaining instruction may be triggered in response to an information obtaining operation of a user, for example, a control for obtaining information may be displayed in the information obtaining terminal, and when an operation, for example, a touch operation, directed to the control by the user is received, the information obtaining terminal triggers the information obtaining instruction. The information acquisition instruction may carry information request data.
Specifically, the information obtaining end may obtain, in response to the information obtaining instruction, a connection address corresponding to the intermediate server, and establish a target long connection with the intermediate server.
In some embodiments, when receiving an information acquisition instruction, an information acquisition end may determine whether a local end supports establishing long connection, for example, whether a webSocket long connection is supported, if so, send a webSocket message for establishing the webSocket long connection to an intermediate server, if not, send a http short connection establishing message to a target server, and determine that information needs to be acquired in an ajax (Asynchronous JavaScript and XML) polling manner. The ajax polling refers to that the information acquisition end needs to inquire whether the server end has new information at intervals when receiving real-time information. If the new message exists, the target server side returns the new message, and if the new message does not exist, the target server side also returns the information to inform the client side that no new message exists. XML (Extensible Markup Language) is a Markup Language for Markup electronic documents to have a structure.
In some embodiments, the establishing the target long connection with the intermediate server in response to the information obtaining instruction includes: responding to the information acquisition instruction, establishing short connection with the intermediate server, and sending a long connection establishment request to the intermediate server through the short connection established with the intermediate server; when receiving connection response information sent by the intermediate server in response to the long connection establishment request, establishing target long connection with the intermediate server; when connection rejection information sent by the intermediate server in response to the long connection establishment request is received, a connection address corresponding to the target server is acquired, short connection is established with the target server, and an information acquisition request corresponding to an information acquisition instruction is sent to the target server through the short connection established with the target server.
Specifically, the connection response information refers to response information agreeing to establish a long connection. The information acquisition end can acquire the connection address of the intermediate server end when receiving the information acquisition instruction, establish short connection with the intermediate server end, and then send a long connection establishment request through the short connection. If the information acquisition end receives the connection rejection information sent by the intermediate server, the short connection can be established with the target server, and the information to be acquired is acquired through the short connection.
Step S304, an information acquisition request is sent to the intermediate server through the target long connection, so that the intermediate server responds to the information acquisition request and sends information request data in the information acquisition request to the target server through the service connection.
Step S306, receiving the target information pushed by the intermediate server through the target long connection, wherein the target information is sent to the intermediate server through the service connection when the target server determines that the information request data has the corresponding target information.
For example, after receiving a webSocket message sent by the information obtaining end through the target long connection, the intermediate server may convert the webSocket message into an http message, establish an http short connection with the target server, send the http message obtained through the conversion to the target server through the http short connection, send the http message when the target server sends the target information to the intermediate server, convert the http message of the target information into the webSocket message by the intermediate server, and send the webSocket message obtained through the conversion to the information obtaining end through the target long connection.
In the network information acquisition method, the information acquisition end and the intermediate server end establish the target long connection, the intermediate server end receives the information acquisition request sent by the target long connection, and then sends the information request data to the target server end through the service connection, so that the target server end can send the target information corresponding to the information request data through the service connection, and meanwhile, the intermediate server end can also actively push the information to the information acquisition end through the established target long connection, and the information acquisition efficiency is improved.
As shown in fig. 4, in one embodiment, a network information acquisition method is provided. The embodiment is mainly illustrated by applying the method to theintermediate server 102 in fig. 1. The method comprises the following steps:
step S402, establishing target long connection with the information acquisition terminal;
step S404, receiving an information acquisition request sent by an information acquisition end through a target long connection, responding to the information acquisition request, and sending information request data in the information acquisition request to a target server end through a service connection;
step S406, receiving target information sent by a target server through service connection, wherein the target information is sent when the target server determines that the information request data has corresponding target information;
step S408, pushing the target information to the information acquisition end through the target long connection.
In the network information acquisition method, the information acquisition end and the intermediate server end establish the target long connection, the intermediate server end receives the information acquisition request sent by the target long connection, and then sends the information request data to the target server end through the service connection, so that the target server end can send the target information corresponding to the information request data through the service connection and can also actively push the information to the information acquisition end through the established target long connection, and the information acquisition efficiency is improved.
According to the network information acquisition system provided by the embodiment of the application, the intermediate server and the target server can be in the same intranet system, so that the intermediate server and the target server can quickly establish service connection, and the efficiency of information acquisition is improved. For example, as shown in fig. 5, a network structure diagram corresponding to the method for receiving network information provided in the embodiment of the present application is provided. Theterminals 502a and 502b are located at one end outside a cluster of CLBs (Cloud Load Balancer), where the CLBs are a key component of a high-availability architecture and are mainly used to improve performance and availability, and distribute traffic to multiple servers through Load balancing, and multiple servers can eliminate single point of failure in this part. Thewebsocket server 504 is an intermediate server, the websocket server is a server supporting establishment of websocket connection and http short connection, thehttp server 506 is a target server, and the http server does not support establishment of websocket connection but supports establishment of http short connection. Thewebsocket server 504 and thehttp server 506 are in the same intranet system, and the terminal 502a and thehttp server 506 transmit data through thewebsocket server 504. Theterminal 502a transmits data to theWebSocket server 504 through the WebSocket interface, and thehttp server 506 sends data to theWebSocket server 504 through an http request. All requests to thehttp server 506 go through the gateway, which has various authentication and security requirements for thewebSocket server 504 like a normal client, so that no additional security issues arise. Meanwhile, the interaction between thewebSocket server 504 and thehttp server 506 belongs to intranet communication, and the network speed is fast, so that the influence on the request response speed is small although one layer of transfer is added. The gateway realizes network interconnection above a network layer and is used for interconnection of two networks with different high-level protocols. The terminal has a unified interface for establishing long connection and short connection, for example, an interface corresponding to webSocket and http, the interface is used for a developer to call, the bottom layer connection is processed by the framework, for example, an external unified interface can be encapsulated on the upper layer of webSocket and http for the developer to call, and the bottom layer can automatically switch to perform long connection with thewebSocket server 504 or establish short connection with thehttp server 506 according to a specific scene, so that the developer does not need to care about details of the bottom layer and is transparent to a front-end developer.
For example, the terminal 502a determines to establish a long connection with thewebSocket server 504 according to the scene, and then establishes a service connection with thehttp server 506 through thewebSocket server 504 to obtain information from thehttp server 506. The terminal 504a determines that thehttp server 506 needs to be directly connected according to the scene, and can establish an http short connection with thehttp server 506 without going through thewebSocket server 504. Therefore, the developer only needs to call the interface to send the request without concern about which form the request is sent, and the method is transparent to the developer.
In some embodiments, the scenario according to which the terminal is based may be at least one of a connection mode supported by the terminal or whether the information to be acquired needs to be acquired multiple times. For example, when multiple acquisitions are needed, the information is acquired by establishing a long connection with thewebsocket server 504. And the mode of establishing long connection with thewebsocket server 504 or directly establishing connection with thehttp server 506 is determined by the connection mode supported by the terminal, and meanwhile, the problem of downward compatibility can be solved. For example, it may be determined whether the terminal supports the webSocket connection. If so, information is obtained from thehttp server 506 by establishing a webSocket connection with thewebSocket server 504. If not, it may be automatically determined that the terminal obtains information by sending an http request to thehttp server 506 every preset duration, for example, by ajax polling. That is, the data may be obtained from the information obtaining end through the http short connection established with thehttp server 506. By this mode, the client development mode on the terminal is the same as before, so the intermediate server is transparent to the client. And the two connected and background communication protocols are http, so that the two connected and background communication protocols can be completely transparent to the target server. That is, the front-end can communicate with the background by using any connection mode, and the selection of the two modes is encapsulated by the underlying basic library, so that the front-end is transparent to the user. The transparent meaning is that the http server can realize the timely sending of information without considering the existence of the webSocket server, so thehttp server 506 can realize the timely sending of the information without changing a communication protocol, and through the two-way parallel architecture, the http protocol is upgraded into the webSocket protocol under the condition that the front end and the rear end are not reconstructed, so that the server has the capability of actively sending data to the client, and the effect of quick seamless access is finally realized.
It should be understood that, although the steps in the above-described flowcharts are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the above-mentioned flowcharts may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or the stages is not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a part of the steps or the stages in other steps.
In some embodiments, as shown in fig. 6, there is provided a network information acquisition apparatus including:
the firstconnection establishing module 602 is configured to establish a target long connection with the intermediate server in response to the information obtaining instruction.
The information obtainingrequest sending module 604 is configured to send an information obtaining request to the intermediate server through the target long connection, so that the intermediate server sends information request data in the information obtaining request to the target server through the service connection in response to the information obtaining request.
The firstinformation receiving module 606 is configured to receive, through the target long connection, target information pushed by the intermediate server, where the target information is sent to the intermediate server through the service connection when the target server determines that the information request data includes corresponding target information.
In some embodiments, the firstconnection establishing module 602 is configured to: responding to the information acquisition instruction, establishing service connection with the intermediate server, and sending a long connection establishment request to the intermediate server through the service connection established with the intermediate server; when receiving connection response information sent by the intermediate server in response to the long connection establishment request, establishing target long connection with the intermediate server; when connection rejection information sent by the intermediate server in response to the long connection establishment request is received, a connection address corresponding to the target server is acquired, short connection is established with the target server, and an information acquisition request corresponding to an information acquisition instruction is sent to the target server through the short connection established with the target server.
In some embodiments, as shown in fig. 7, there is provided a network information acquisition apparatus, including:
a secondconnection establishing module 702, configured to establish a target long connection with the information obtaining end.
And an information requestdata sending module 704, configured to receive the information obtaining request sent by the information obtaining end through the target long connection, and send information request data in the information obtaining request to the target server through the service connection in response to the information obtaining request.
The secondinformation receiving module 706 is configured to receive target information sent by the target server through the service connection, where the target information is sent when the target server determines that the information request data has corresponding target information.
And the pushingmodule 708 is configured to push the target information to the information obtaining end through the target long connection.
For specific limitations of the network information acquiring apparatus, reference may be made to the above limitations of the network information acquiring method, which is not described in detail herein. The modules in the network information acquisition device may be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing the target information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a network information acquisition method.
In some embodiments, a computer device is provided, and the computer device may be an information acquisition end, and an internal structure diagram thereof may be as shown in fig. 9. The computer device comprises a processor, a memory, a communication interface, a display screen and an input device which are connected through a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The communication interface of the computer device is used for communicating with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a network information acquisition method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the configurations shown in fig. 8 and 9 are merely block diagrams of some configurations relevant to the present disclosure, and do not constitute a limitation on the computing devices to which the present disclosure may be applied, and that a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In some embodiments, there is provided a computer device comprising a memory having a computer program stored therein and a processor that when executed performs the steps of: responding to the information acquisition instruction, and establishing target long connection with the intermediate server; sending an information acquisition request to an intermediate server through the target long connection, so that the intermediate server responds to the information acquisition request and sends information request data in the information acquisition request to the target server through the service connection; and receiving target information pushed by the intermediate server through the target long connection, wherein the target information is sent to the intermediate server through the service connection when the target server determines that the information request data has the corresponding target information.
In some embodiments, there is provided a computer device comprising a memory having a computer program stored therein and a processor that when executed performs the steps of: establishing target long connection with an information acquisition end; receiving an information acquisition request sent by an information acquisition end through a target long connection, responding to the information acquisition request, and sending information request data in the information acquisition request to a target server end through a service connection; receiving target information sent by a target server through service connection, wherein the target information is sent when the target server determines that corresponding target information exists in information request data; and pushing the target information to the information acquisition end through the target long connection.
In some embodiments, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of: responding to the information acquisition instruction, and establishing target long connection with the intermediate server; sending an information acquisition request to an intermediate server through the target long connection, so that the intermediate server responds to the information acquisition request and sends information request data in the information acquisition request to the target server through the service connection; and receiving target information pushed by the intermediate server through the target long connection, wherein the target information is sent to the intermediate server through the service connection when the target server determines that the information request data has the corresponding target information.
In some embodiments, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of: establishing target long connection with an information acquisition end; receiving an information acquisition request sent by an information acquisition end through a target long connection, responding to the information acquisition request, and sending information request data in the information acquisition request to a target server end through a service connection; receiving target information sent by a target server through service connection, wherein the target information is sent when the target server determines that corresponding target information exists in information request data; and pushing the target information to the information acquisition end through the target long connection.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), for example.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is specific and detailed, but not to be understood as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, and these are all within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.