CN108366277B - Bullet screen server connection method, client and readable storage medium - Google Patents

Bullet screen server connection method, client and readable storage medium Download PDF

Info

Publication number
CN108366277B
CN108366277B CN201810293884.2A CN201810293884A CN108366277B CN 108366277 B CN108366277 B CN 108366277B CN 201810293884 A CN201810293884 A CN 201810293884A CN 108366277 B CN108366277 B CN 108366277B
Authority
CN
China
Prior art keywords
bullet screen
server
candidate
list
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810293884.2A
Other languages
Chinese (zh)
Other versions
CN108366277A (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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810293884.2A priority Critical patent/CN108366277B/en
Publication of CN108366277A publication Critical patent/CN108366277A/en
Application granted granted Critical
Publication of CN108366277B publication Critical patent/CN108366277B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/254Management at additional data server, e.g. shopping server, rights management server
    • H04N21/2541Rights Management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/258Client or end-user data management, e.g. managing client capabilities, user preferences or demographics, processing of multiple end-users preferences to derive collaborative data
    • H04N21/25808Management of client data
    • H04N21/25816Management of client data involving client authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/478Supplemental services, e.g. displaying phone caller identification, shopping application
    • H04N21/4788Supplemental services, e.g. displaying phone caller identification, shopping application communicating with other users, e.g. chatting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/633Control signals issued by server directed to the network components or client
    • H04N21/6332Control signals issued by server directed to the network components or client directed to client
    • H04N21/6334Control signals issued by server directed to the network components or client directed to client for authorisation, e.g. by transmitting a key
    • H04N21/63345Control signals issued by server directed to the network components or client directed to client for authorisation, e.g. by transmitting a key by transmitting keys
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • H04N21/64322IP

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Databases & Information Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Computer Graphics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention provides a bullet screen server connection method, a client and a readable storage medium. The bullet screen server connection method applied to the client comprises the following steps: connecting to a gateway server under the condition that the preset application program is detected to start the bullet screen function; acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server; connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy; if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, acquiring a second candidate bullet screen server list, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server; and connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.

Description

Bullet screen server connection method, client and readable storage medium
Technical Field
The invention relates to the technical field of electronics, in particular to a bullet screen server connection method, a client and a readable storage medium.
Background
At present, the network live broadcast is more and more popular, and when the live broadcast platform is in live broadcast, audiences send a bullet screen to play a good role in interacting with a main broadcast. Because the data volume of the bullet screen is very big and the real-time of the bullet screen, the server system of the live broadcast platform independently opens the bullet screen server, and the full time is responsible for receiving and sending the bullet screen information. And the independent bullet screen output server sends and receives bullet screens with the client by using long TCP connection. For the TCP connection process, various network problems may occur, such as: the client is in different networks, the network is not reachable, a certain IP address chain is not connected, a port connected with TCP is occupied, the bullet screen server is overloaded, DNS hijacking is carried out, disaster tolerance of the bullet screen server is realized, and the like, so that a large number of clients cannot be connected with the bullet screen server.
Disclosure of Invention
The embodiment of the invention provides a bullet screen server connection method, a client and a readable storage medium, which are used for improving the success rate of connecting the client with a bullet screen server.
In a first aspect, the present invention provides a bullet screen server connection method, applied to a client, including:
connecting to a gateway server under the condition that the preset application program is detected to start the bullet screen function;
acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server;
connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy;
if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, acquiring a second candidate bullet screen server list, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server;
and connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.
Optionally, the connecting, according to a first preset policy, the bullet screen servers in the first candidate bullet screen server list includes:
and selecting one bullet screen server from the first candidate bullet screen server list in sequence at random for connection until the connection is successful or the bullet screen servers in the first candidate bullet screen server list are all failed to be connected.
Optionally, the randomly selecting one bullet screen server in sequence from the first candidate bullet screen server list to connect includes:
sequentially and randomly selecting one bullet screen server from the first candidate bullet screen server list to obtain the domain name address of the randomly selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the randomly selected bullet screen server;
and connecting the randomly selected bullet screen server based on the IP address and the port number of the randomly selected bullet screen server.
Optionally, the connecting, according to a second preset policy, the bullet screen servers in the second candidate bullet screen server list includes:
and selecting one bullet screen server from the second candidate bullet screen server list in sequence at random for connection until the connection is successful.
Optionally, the connecting, according to a second preset policy, the bullet screen servers in the second candidate bullet screen server list includes:
sorting the bullet screen servers in the second candidate bullet screen server list according to the connection power from high to low;
and sequentially connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the connection power from high to low until the connection is successful.
Optionally, after the bullet screen servers in the second candidate bullet screen server list are connected according to the second preset policy, the method further includes:
and if all the bullet screen servers in the second candidate bullet screen server list are failed to be connected, connecting the bullet screen servers based on the HTTP protocol.
In a second aspect, an embodiment of the present invention provides a bullet screen server connection method, which is applied to a bullet screen server system, where the bullet screen server system includes a plurality of gateway servers and a plurality of bullet screen servers, and the method includes:
the method comprises the steps that under the condition that a first connection request sent by a client is received by a gateway server, a first candidate barrage server list is sent to the client in response to the first connection request, and the first candidate barrage server list comprises domain name addresses of at least one barrage server;
if the gateway server receives information that the connection of the client fails for all the bullet screen servers in the first candidate bullet screen server list, sending a second candidate bullet screen server list to the client, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server;
and if the client determines the connected bullet screen server based on the second candidate bullet screen server list, the bullet screen server responds to a second connection request sent by the client under the condition that the bullet screen server receives the second connection request, and the connection with the client is established.
In a third aspect, an embodiment of the present invention provides a client, including:
the first connection unit is used for connecting to the gateway server under the condition that the preset application program is detected to start the barrage function;
the first acquisition unit is used for acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server;
the second connection unit is used for connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy;
a second obtaining unit, configured to obtain a second candidate bullet screen server list if all bullet screen servers in the first candidate bullet screen server list are failed to connect, where the second candidate bullet screen server list includes an IP address and a port number of each bullet screen server in at least one bullet screen server;
and the third connecting unit is used for connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.
Optionally, the second connection unit is configured to:
and selecting one bullet screen server from the first candidate bullet screen server list in sequence at random for connection until the connection is successful or the bullet screen servers in the first candidate bullet screen server list are all failed to be connected.
Optionally, the second connection unit is configured to:
sequentially and randomly selecting one bullet screen server from the first candidate bullet screen server list to obtain the domain name address of the randomly selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the randomly selected bullet screen server;
and connecting the randomly selected bullet screen server based on the IP address and the port number of the randomly selected bullet screen server.
Optionally, the third connection unit is configured to:
and selecting one bullet screen server from the second candidate bullet screen server list in sequence at random for connection until the connection is successful.
Optionally, the third connection unit is configured to:
sorting the bullet screen servers in the second candidate bullet screen server list according to the connection power from high to low;
and sequentially connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the connection power from high to low until the connection is successful.
Optionally, the client further includes:
and the fourth connecting unit is used for connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy and then connecting the bullet screen servers based on the HTTP protocol if the bullet screen servers in the second candidate bullet screen server list are failed to connect.
In a fourth aspect, an embodiment of the present invention provides a client, where the client includes a processor, and the processor is configured to implement, when executing a computer program stored in a memory, the steps of the bullet screen server connection method described in the foregoing first aspect embodiment.
In a fifth aspect, an embodiment of the present invention provides a readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the bullet screen server connection method as described in the foregoing first and second aspect embodiments.
One or more technical solutions in the embodiments of the present application have at least one or more of the following technical effects:
in the technical scheme of the embodiment of the invention, the bullet screen server system comprises the gateway server and the bullet screen server, the functions required to be completed by the gateway server are fewer, and the client can be easily connected with the gateway server. Under the condition that the client starts the bullet screen function of the preset application program, the client is firstly connected with the gateway server, and after a first candidate bullet screen server list issued by the gateway server is received, the IP address and the port number of the bullet screen server are obtained by analyzing the domain name address in the first candidate bullet screen server list. The IP address of the barrage server cannot be acquired due to the fact that the DNS is hijacked, or the acquired IP address is not connected with the barrage server. If all the bullet screen servers in the first candidate bullet screen server list fail to be connected, the client side can also obtain a second candidate bullet screen server list, the second candidate bullet screen server list comprises the IP address and the port number of the bullet screen server, the client side can be directly connected with the bullet screen servers in the second candidate bullet screen server list based on the IP address and the port number, and therefore the success rate of the client side in being connected with the bullet screen servers can be effectively improved.
Drawings
Fig. 1 is a flowchart of a bullet screen server connection method according to a first embodiment of the present invention;
fig. 2 is a flowchart of a bullet screen server connection method according to a second embodiment of the present invention;
FIG. 3 is a diagram of a client according to a third embodiment of the present invention;
fig. 4 is a schematic diagram of a client according to a fourth embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a bullet screen server connection method, a client and a readable storage medium, which are used for improving the success rate of connecting the client with a bullet screen server. The bullet screen server connection method is applied to a client and comprises the following steps: connecting to a gateway server under the condition that the preset application program is detected to start the bullet screen function; acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server; connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy; if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, acquiring a second candidate bullet screen server list, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server; and connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.
The technical solutions of the present invention are described in detail below with reference to the drawings and specific embodiments, and it should be understood that the specific features in the embodiments and examples of the present invention are described in detail in the technical solutions of the present application, and are not limited to the technical solutions of the present application, and the technical features in the embodiments and examples of the present application may be combined with each other without conflict.
The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
Examples
Referring to fig. 1, a first embodiment of the present invention provides a bullet screen server connection method applied to a client, where the bullet screen server connection method includes the following steps:
s101: connecting to a gateway server under the condition that the preset application program is detected to start the bullet screen function;
s102: acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server;
s103: connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy;
s104: if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, acquiring a second candidate bullet screen server list, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server;
s105: and connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.
Specifically, the bullet screen server connection method in this embodiment is mainly applied to a client installed with a preset application program, where the preset application program may be a live application program or a video-type application program, and of course, may also be other application programs with a bullet screen function, and the application is not limited herein. Further, in this embodiment, because live broadcast application's barrage information quantity is great, and the real-time is higher, barrage server system has included a plurality of gateway servers and a plurality of barrage servers, and a plurality of barrage servers are connected to every gateway server. When the bullet screen function is started, a preset application program of the client needs to be connected with the gateway server first, and then connected with the bullet screen server through the gateway server.
First, in a case where it is detected that the preset application opens the bullet screen function, a connection is made to the gateway server through step S101. The gateway servers need to complete a small number of functions, network load is light, the same gateway server can support connection of a plurality of clients, and the power of the clients connected to the gateway servers is high. When a client connects to a gateway server, a PHP (Hypertext Preprocessor) server pulls an IP list of candidate gateway servers by an HTTP (Hypertext Transfer Protocol) request, and the PHP server selects an IP address and a port of a gateway server with a relatively small load to form an IP list of the candidate gateway servers according to a connection client load condition of each gateway server in the entire network. Such as: and determining that the IP addresses and port numbers of the gateway servers with the client connection quantity smaller than the preset quantity are added to the IP list of the candidate gateway servers.
And then, the PHP server issues the determined IP list of the gateway server to the client. And after the client acquires the IP list of the gateway server from the PHP server, a random strategy is adopted, one IP and one port are randomly selected for connection each time, if the connection is carried out, the connection step of the gateway server is completed, otherwise, the rest of the IPs and the rest of the ports are randomly selected again from the IP list of the gateway server for connection until the gateway server is successfully connected.
Further, after connecting to the gateway server, step S102 is executed, specifically, in this embodiment, the client sends a first connection request for connecting to the bullet screen server to the gateway server, and after the gateway server receives the first connection request, the gateway server determines the bullet screen servers in the first candidate bullet screen server list according to the load condition and the geographic location of each bullet screen server. Specifically, the bullet screen servers with low load and close to the client position may be selected as the first candidate bullet screen server list. Considering the locality of each client, the present embodiment first provides a way of connecting bullet screen servers through Domain Name System (DNS) resolution, and the determined first candidate bullet screen server list includes a domain name address of at least one bullet screen server. And after the first candidate barrage server list is determined, the gateway server sends the first candidate barrage server list to the client.
After receiving the first candidate barrage server list, the client performs step S103, which may include the following steps: and selecting one bullet screen server from the first candidate bullet screen server list in sequence at random for connection until the connection is successful or the bullet screen servers in the first candidate bullet screen server list are all failed to be connected.
Wherein, the randomly selecting one bullet screen server in sequence from the first candidate bullet screen server list for connection comprises: sequentially and randomly selecting one bullet screen server from the first candidate bullet screen server list to obtain the domain name address of the randomly selected bullet screen server; analyzing the domain name address to obtain the IP address and the port number of the randomly selected bullet screen server; and connecting the randomly selected bullet screen server based on the IP address and the port number of the randomly selected bullet screen server.
Specifically, in this embodiment, after receiving the first candidate barrage server list, in order to implement load balancing as much as possible, the client uses a random policy to connect the barrage servers in the first candidate barrage server list. Specifically, one bullet screen server can be sequentially and randomly selected from the first candidate bullet screen server list to connect until the connection is successful or all the bullet screen servers in the first candidate bullet screen server list are failed to connect.
When the randomly selected bullet screen server is connected, the client obtains the domain name address corresponding to the client, the domain name resolver resolves the IP address and the port number corresponding to the domain name address, namely, the corresponding bullet screen server can be connected based on the resolved IP address and the resolved port number.
Of course, in the method in this embodiment, the domain name addresses of all the bullet screen servers in the first candidate bullet screen server list may also be directly resolved to obtain the IP address and the port number corresponding to each bullet screen server in the list, and then a group of IP addresses and port numbers are randomly selected to connect. In a specific implementation process, a mode of connecting the bullet screen servers in the first candidate bullet screen server list may be determined according to actual needs, and the application is not limited herein.
When the client is successfully connected to one bullet screen server, the client can perform interaction of bullet screen information with the connected bullet screen server, and if the connection fails, the client can randomly select one bullet screen server from the rest bullet screen servers in the first candidate bullet screen server list to perform connection until the connection is successful. Because the domain name address is hijacked, the client cannot analyze the IP address of the bullet screen server, or the acquired IP address is not connected with the bullet screen server, the client also fails to connect all the bullet screen servers in the first candidate bullet screen server list.
In the case that all the bullet screen servers in the first candidate bullet screen server list fail to connect, step S104 is executed. Specifically, after the client resolves the IP address and the port number of the bullet screen server in the first candidate bullet screen server list in the domain name resolution manner, the client connects the bullet screen server in the first candidate bullet screen server list based on the resolved IP address and port number, and if the domain name is hijacked or other reasons cause the client to be not connected with the bullet screen server in the first candidate bullet screen server list. At this time, in order to ensure that the client can be connected with the bullet screen server as much as possible, the client feeds back the information of the connection failure to the gateway server, and after receiving the feedback information, the gateway server issues a second candidate bullet screen server list to the client again through the gateway server, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server. The IP address and the port number in the list are the guaranteed-base IP, where the guaranteed-base IP refers to the IP address and the port number of the bullet screen server directly sent by the gateway server to the client, and the client can directly connect the corresponding bullet screen server through the guaranteed-base IP, and the client does not need to perform domain name resolution to obtain the IP address and the port number corresponding to the domain name address as in the domain name resolution policy.
Further, in this embodiment, the gateway server may determine the IP address and the port number of the bullet screen server in the second candidate bullet screen server list according to the load condition and the port occupation condition of each bullet screen server. Specifically, the bullet screen servers with low load and idle ports may be selected from the second candidate bullet screen server list, where the selected bullet screen servers include their IP addresses and corresponding port numbers. Further, the client may connect to the corresponding bullet screen server based on the IP address and port number of each bullet screen server in the second candidate bullet screen server list. Further, the client may also use an IP list corresponding to the latest connected bullet screen server as the second candidate bullet screen server list.
Further, by performing the connection in step S105, when connecting the bullet screen servers in the second list of candidate bullet screen servers, the following two ways may be adopted, but not limited to:
the first mode is as follows: and selecting one bullet screen server from the second candidate bullet screen server list in sequence at random for connection until the connection is successful.
Specifically, in this embodiment, in order to enable each IP address and port of the bullet screen server to balance load pressure, the client may also use a random policy to connect the bullet screen servers in the second candidate bullet screen server list. Specifically, a group of IP addresses and port numbers of one bullet screen server may be sequentially and randomly selected from the second candidate bullet screen server list for connection until connection is successful or connection of all bullet screen servers in the second candidate bullet screen server list fails.
And when the client is successfully connected to one bullet screen server, the client can perform bullet screen information interaction with the connected bullet screen server, and if the connection fails, the client randomly selects one bullet screen server from the rest bullet screen servers in the second candidate bullet screen server list to connect until the connection is successful. Since the acquired IP address is not connected to the bullet screen server, the client fails to connect all the bullet screen servers in the second candidate bullet screen server list.
The second mode is as follows: sorting the bullet screen servers in the second candidate bullet screen server list according to the connection power from high to low; and sequentially connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the connection power from high to low until the connection is successful.
Specifically, in this embodiment, the client records a historical connection record of the preset application program connecting to each bullet screen server during the bullet screen function starting period, including a connection success record and a connection failure record. Such as: the live broadcast application program starts the barrage function in a preset time range, and records of the barrage server connected during the period of watching a first live broadcast at each time comprise: and recording the IP address 1 of the bullet screen server 1 in successful and failed connection within the latest 24 hours from the current moment, wherein the successful connection frequency is N1, and the failed connection frequency is N2. And recording the IP address 2 of the bullet screen server 2 which is successfully and unsuccessfully connected within the latest 24 hours from the current moment, wherein the successful connection frequency is N3, and the failed connection frequency is N4. And recording the IP address 3 of the bullet screen server 3 which is successfully and unsuccessfully connected within the latest 24 hours from the current moment, wherein the successful connection frequency is N5, and the failed connection frequency is N6.
Through the history connection records, it can be determined that the success rate of the client connecting to the bullet screen server 1 is N1/(N1+ N2+ N3+ N4+ N5+ N6), the success rate of the client connecting to the bullet screen server 2 is N3/(N1+ N2+ N3+ N4+ N5+ N6), and the success rate of the client connecting to the bullet screen server 3 is N5/(N1+ N2+ N3+ N4+ N5+ N6). Of course, the success rate of connecting each bullet screen server can also be defined in other ways, such as: continuing with the above example, the success rate of the client connecting to the bullet screen server 1 is defined as N1-N2, the success rate of the client connecting to the bullet screen server 2 is defined as N3-N4, and the success rate of the client connecting to the bullet screen server 3 is defined as N5-N6. In a specific implementation process, the success rate of connecting the client to each bullet screen server can be defined according to actual needs, and the application is not limited herein.
After the client receives the second candidate barrage server list, the success rate of the client in connecting each barrage server in the second candidate barrage server list can be determined based on the historical connection records. And then, the bullet screen servers in the second candidate bullet screen server list are sequentially connected according to the sequence of the connection power from high to low until the connection is successful.
Further, in this embodiment, the client may also perform bullet screen server connection according to the list of candidate bullet screen servers received last time. Such as: for the live broadcast application program, the live broadcast application program is connected with the barrage server once when the client enters each direct room, and the live broadcast application program is disconnected when the client exits the direct broadcast room. In the method in this embodiment, each time the client enters the live broadcast room, the IP lists corresponding to the candidate barrage server lists (the first candidate barrage server list or the second candidate barrage server list) delivered by the last gateway server may also be randomly selected or connected in the order of the success rates from high to low, and the random connection policy and the policy of connection in the order of the success rates from high to low are as described above, which is not described herein again. For the client, the information of the connection is recorded every time the bullet screen server is connected, whether the connection of each IP address is successful or not is recorded, if the connection of each IP address is failed, the connection is failed, and if the connection of each IP address is successful, the connection is successfully recorded. The record of the IP address connected by the client at each time can be stored in the local of the client and also can be uploaded to the server.
Since the acquired IP address is not connected to the bullet screen server, the client fails to connect all the bullet screen servers in the second candidate bullet screen server list.
In a case that all the bullet screen servers in the second candidate bullet screen server list are failed to connect, the bullet screen server connection method in this embodiment further provides a bullet screen server connection policy based on HTTP (HyperText Transfer Protocol), so that if all the bullet screen servers in the second candidate bullet screen server list are failed to connect, the method further includes: and connecting the bullet screen server based on the HTTP.
Specifically, in this embodiment, the bullet screen server system includes a plurality of bullet screen servers, and since the server connection speed based on the TCP/IP protocol is fast, the client can connect the bullet screen server fast, most of the bullet screen servers are servers based on the TCP/IP protocol, and a small part of the bullet screen servers are servers based on the HTTP protocol. Such as: the bullet screen server system comprises 90 bullet screen servers based on a TCP/IP protocol, and comprises 10 bullet screen servers based on an HTTP protocol.
Further, the hyperlink address of the bullet screen server based on the HTTP protocol may be issued to the client through the gateway server based on the request of the client, for example: and feeding back connection failure information to the gateway server under the condition that the client fails to connect all the bullet screen servers in the second candidate bullet screen list, and after receiving the connection failure information, the gateway server issues a super connection address of the bullet screen server based on the HTTP protocol to the client.
Meanwhile, the super connection address of the bullet screen server based on the HTTP protocol can also be issued to each client in the whole network in advance, for example: when a bullet screen server based on an HTTP protocol is built, the corresponding super connection address is sent to a client of the whole network. And each client locally stores the super connection address of the bullet screen server based on the HTTP protocol, acquires the locally stored super connection address of the bullet screen server based on the HTTP protocol under the condition that the client fails to connect all bullet screen servers in the second candidate bullet screen list, and then connects the locally stored super connection address of the bullet screen server based on the HTTP protocol to the corresponding bullet screen server based on the HTTP protocol through the super connection address. The method supports sending and receiving of the barrage through the HTTP mode, so that when the barrage server is not connected through domain name resolution and a bottom-preserving IP strategy, the barrage server based on the HTTP can be connected based on the HTTP protocol, and the client can be ensured to be successfully connected to the barrage server to send and receive the barrage information.
In this embodiment, when connecting the bullet screen server based on the HTTP protocol, the following two ways can be adopted, but not limited to:
the first mode is as follows: and selecting one bullet screen server from the bullet screen servers based on the HTTP protocol in sequence at random for connection based on the HTTP protocol until the connection is successful.
Specifically, in this embodiment, in order to enable each HTTP protocol-based bullet screen server of the bullet screen servers to balance load pressure, the client may also use a random policy to connect the HTTP protocol-based bullet screen servers. Specifically, one bullet screen server can be sequentially and randomly selected from the bullet screen servers based on the HTTP protocol to connect until the connection is successful. In this embodiment, the bullet screen server based on the HTTP protocol may further set a maximum connection number, if the client requests to connect to the bullet screen server based on the HTTP protocol, if the number of the clients currently connected to the bullet screen server is the set maximum connection number, the bullet screen server may reject the connection request of the client, and the client may randomly select one of the remaining bullet screen servers based on the HTTP protocol again to connect until the connection is successful.
The second mode is as follows: acquiring the number of clients connected with each bullet screen server based on an HTTP (hyper text transport protocol); determining a bullet screen server with the least number of connected clients; and connecting the bullet screen server with the least number of connected clients based on the HTTP.
Specifically, in this embodiment, in the case that the super connection address of the bullet screen server based on the HTTP protocol is issued to the client through the gateway server based on the request of the client, the gateway server may also issue the number of clients connected to each bullet screen server based on the HTTP protocol at the current time, so that after the client learns the number of clients connected to each bullet screen server based on the HTTP protocol at the current time, the bullet screen server with the least number of connected clients may be determined, and then the bullet screen server is connected based on the HTTP protocol. Therefore, the success rate and the connection speed of the client side to the bullet screen server can be further improved, and the user experience is improved.
Further, in this embodiment, when the client detects that the preset application starts the bullet screen function, since the preset application is usually installed in the mobile client, the network state of the mobile client may change in real time. Therefore, it is also necessary to determine whether to perform the operation of connecting the bullet screen server according to the current network connection state of the client. Specifically, the method comprises the following steps: detecting and acquiring the current network connection state of the client; if the current network connection state is in a preset network connection state, connecting a bullet screen server according to a preset strategy, wherein the preset network connection state is a wireless local area network connection state or a wireless wide area network connection state; and if the current network connection state is in a non-preset network connection state, stopping connecting the bullet screen server.
Specifically, in this embodiment, the ue is triggered to detect the current network connection status in the following several cases. Firstly, after a preset application program is started, a bullet screen function of the preset application program is started, and when the bullet screen function is triggered to play a video, a client detects a network connection state. Such as: the preset application program is a live application program, when the live application program is started, the barrage function of the live application program is started, and if the live application program enters a first live broadcast room, the client detects the current network connection state. Secondly, when the barrage function is started during the video playing after the preset application program is started, the client detects the network connection state. Such as: the live broadcast application program enters a first live broadcast room after being started, a user starts a barrage function in the first live broadcast room, and at the moment, the client side can detect the current network connection state. Thirdly, during the running period of the preset application program in the client, if the preset application program starts the barrage function, the client may detect the current network connection state according to a preset time interval (e.g., 5 minutes, 10 minutes, etc.).
Furthermore, if the current network connection state is in a preset network state such as a wireless local area network connection state (such as a wifi network connection) or a wireless wide area network connection state (such as a 3G/4G network connection), the bullet screen server can be connected according to a preset strategy. If the current network connection state is in the non-preset network connection state, such as: and if the client is not connected with the network, stopping connecting the bullet screen server. For the situation of no network, if the bullet screen server is not connected, the client is not reconnected, and the bullet screen server is reconnected when the preset network is connected to the client and is in the preset network connection state. Such as: the mobility of the client possibly causes the network state of the client to change, and the client moves to an area which is not covered by the wifi network under the condition of connecting the wifi network, so that the network connection state is detected to be switched from the preset network state to a non-preset network state, at the moment, the client can be disconnected with the bullet screen server, and the bullet screen server is reconnected after the client is reconnected to the wifi network.
Further, in this embodiment, if the current network connection state is in the wireless wide area network connection state, a prompt message is output to prompt whether to confirm connection with the bullet screen server; and if the confirmation information aiming at the prompt information is received, connecting the bullet screen server according to a preset strategy.
Specifically, in this embodiment, if the current network connection state is in the wireless wide area network connection state, because the wireless wide area network generally needs to charge according to the flow, the client needs to output the prompt information for prompting whether to confirm to connect the bullet screen server, the prompt information can be a voice prompt, a text prompt, and the like, and if the user receives the confirmation information for the prompt information, the client can connect the bullet screen server to avoid causing unnecessary economic overhead of the user.
Further, in this embodiment, if it is determined that the current network connection state of the client is in the preset network connection state, the network speed, the remaining power of the client, the memory occupancy rate, and other factors may be further considered to finally determine whether to connect the bullet screen server. Specifically, one or more preset conditions may be set, including: the network speed of the currently connected network is greater than the preset network speed, the residual electric quantity of the client is greater than the preset electric quantity, and the memory occupancy rate is less than the preset memory occupancy rate. And when the one or more preset conditions are met, determining to connect the bullet screen server according to a preset strategy.
Further, in this embodiment, under the condition that it is determined that the current network state of the client is in the preset network state, the connection policy based on domain name resolution, the guaranteed IP address connection policy, and the HTTP connection policy may be adopted in the manner of connecting the bullet screen server according to the preset policy, which is described in detail in the foregoing embodiments and is not described herein again.
Further, it should be noted that in the situation of triggering the client to detect the current network connection state, if the situation is the third situation, during the running period of the preset application program in the client, if the preset application program starts the barrage function, the client may detect the current network connection state according to a preset time interval (e.g., 5 minutes, 10 minutes, etc.). If the network connection state detected last time is in a non-preset network state, the network connection state at the current time is in a preset network state, and the time interval from the current time to the last successful connection of the bullet screen server is smaller than a preset time interval (such as 10 minutes, 20 minutes and the like), the client can be connected with the bullet screen server again, when the bullet screen server is connected, the bullet screen server which is successfully connected last time at the client can be directly connected, and if the connection fails, the bullet screen server can be connected again according to the method for connecting the bullet screen server in the previous embodiment.
Through the mode, the client can be connected with the bullet screen server only when the client is in the preset network state, so that the consumption of a CPU (central processing unit) can be reduced as much as possible, the power consumption is reduced, and the heat productivity is also reduced.
Further, in this embodiment, if it is detected that the network connection status of the client changes from the preset network connection status to the non-preset network connection status, the connection of the bullet screen server is stopped.
Specifically, the client needs to monitor the network connection state, and if it is detected that the network connection state of the client changes from the preset network connection state to the non-preset network connection state, the client does not try to connect the bullet screen server again, but tries to connect the bullet screen server again until the client is in the preset network connection state.
Further, in this embodiment, after the client connects to the bullet screen server according to the preset policy, the client needs to monitor the foreground and background running states of the preset application program, and adjust the connection of the bullet screen server according to the running states. The method can be realized by the following steps: monitoring the running state of a preset application program; if the running state of the preset application program is switched from the foreground running state to the background running state, stopping connecting the bullet screen server; and if the running state of the preset application program is switched from the background running state to the foreground running state, reconnecting the bullet screen server.
Specifically, in this embodiment, during the period when the client connects to the bullet screen server and completes receiving and sending of the bullet screen information, the running state of the preset application program is monitored, for example: checking the running state of the preset application program according to a preset time interval (such as 5 minutes, 10 minutes and the like), if the preset application program is in a foreground running state, the client side continues to transmit the bullet screen information with the connected bullet screen server, if the running state of the preset application program is switched to a background running state from the foreground running state, for the live broadcast application program, exiting from the background means that the audience cannot see the live broadcast and cannot see the bullet screen at the same time, therefore, the client side can stop connecting the bullet screen server and cannot continuously connect the bullet screen server. And when detecting that the preset application program is switched to the foreground operation again, the bullet screen server can be reconnected.
Further, in this embodiment, a waiting duration (e.g., 5 minutes, 10 minutes, etc.) may be set, when the preset application program is switched to the background operation, if the duration of the background operation reaches the waiting duration, the client interrupts the connection with the bullet screen server, and when the duration of the background operation of the preset application program does not reach the waiting duration, the client maintains the connection with the bullet screen server, so that when the preset application program is switched back to the foreground operation state within a short time, the client may receive and send the bullet screen information in time. When the preset application program is in the background running state for a long time, the client can automatically interrupt the connection with the bullet screen server, so that the problems of extra heat, occupation of a CPU (central processing unit) of the client, electric quantity consumption and the like caused by the connection of the bullet screen server during the background running of the preset application program are avoided. When the preset application program in the background running state is switched to the foreground running state again, if the connection between the client and the bullet screen server is interrupted during the background running state, at the moment, the bullet screen server which is successfully connected last time by the client can be directly connected, and if the connection fails, the bullet screen server can be connected again according to the mode of connecting the bullet screen server in the embodiment, and the repeated description is omitted in the application.
Further, in this embodiment, since the client connection gateway server and the bullet screen server are both based on the TCP/IP protocol, any person can make a connection once knowing the IP address and the port number of the server due to the characteristics of the TCP/IP. In order to prevent malicious attacks by an illegal client and improve the security of a bullet screen server system, in the method in this embodiment, in the process of connecting the client to the bullet screen server, the identity of the client needs to be authenticated, specifically, the bullet screen server system includes a plurality of gateway servers and a plurality of bullet screen servers. Therefore, when the gateway server and the barrage server are connected, the client identity needs to be authenticated, and the authentication process is as follows:
the method comprises the steps that a gateway server obtains first information to be verified and first identity information sent by a client under the condition that a first connection request sent by the client is received;
the gateway server generates first verification information based on the first identity information and a first preset key;
if the first information to be verified is matched with the first verification information, the gateway server responds to the first connection request, establishes connection with the client and sends the bullet screen server information to be connected to the client;
the method comprises the steps that under the condition that a bullet screen information server receives a second connection request sent by a client, second information to be verified and second identity information sent by the client are obtained, wherein the bullet screen server determines the connected bullet screen server for the client based on the bullet screen server information to be connected, and the second connection request is a connection request sent to the bullet screen server after being connected with a gateway server;
the bullet screen server generates second verification information based on the second identity information and a second preset secret key;
and if the second information to be verified is matched with the second verification information, the bullet screen server responds to the second connection request.
Specifically, in this embodiment, when the client detects that the preset application program starts the bullet screen function, and when the client determines the connected gateway server by using the method in the foregoing embodiment, the client sends the first connection request, the first information to be authenticated, and the first identity information to the gateway server. If the client is a valid client, the client receives a first key sent by the gateway server in advance, and further based on the first key and the first identity information, the client can generate first information to be verified for the gateway server to verify, in this embodiment, the first identity information includes any one or a combination of multiple kinds of version number information of the client, client type information, a device identifier of the client, and first timestamp information for sending the first connection request.
When the client connects to the gateway server, version number information version, clienttype, device unique ID (i.e. device identifier) of the client, and timestamp information time of the current connection may be available. The information is spliced together and encrypted, and then the MD5 value of the information is calculated to obtain the authenticated KEY value, wherein the KEY value is the first information to be verified. The KEY value depends on time and client information, so that the value calculated at each moment of time for each client is changed, thereby raising the threshold for its forgery. The concrete implementation is as follows:
the first encrypted data is generated by an AES Encryption data1 (version + clienttype + ID + time1, aeskey1), wherein AES Encryption is an interface of an AES (Advanced Encryption Standard) Encryption algorithm, aeskey1 is a key value used by the AES Encryption algorithm, the key value is a first key sent to a legal client by a gateway server in advance, and the gateway server and the legal client use the same value. And finally, obtaining an encrypted encryptData1 result, wherein the encryptData1 is the first encrypted data generated by the client by adopting an AES encryption algorithm.
Then, the first information to be verified is generated by a command Key1 ═ md5.create (encrypt data1), which obtains the first information to be verified Key1 by calling the MD5 algorithm.
When the client connects to the gateway server, the client will carry the first information Key1 to be verified and the first identity information. After receiving the information reported by the client, the gateway server generates, in the same manner and based on the first identity information and the first Key, the first verification information Key2 by using the same encryption algorithm. Following the above example, the gateway server also generates first encrypted data by using an AES encryption algorithm based on version number information version of the client, client type information clienttype, device unique ID (i.e., device identification) of the client, and timestamp information time1 of the current connection, and then calculates first verification information Key2 by using an MD5 encryption algorithm.
Furthermore, if the client is a legal client, the first verification information Key2 generated by the gateway server is consistent with the first information Key2 to be verified reported by the legal client, so that the matching can be determined to be successful, and the client can pass the verification of the gateway server, and the gateway server responds to the connection request of the client to establish the connection with the client. The gateway server may send the bullet screen server information to be connected to the client, for example, a process of sending the first candidate bullet screen server list and the second candidate bullet screen server list in the foregoing embodiment, which is not described herein again.
Further, when the client connects to the bullet screen server through the bullet screen server information to be connected sent by the gateway server, the connected bullet screen server also needs to further verify the client. The specific process is similar to the gateway server authentication process.
Specifically, when the client determines the bullet screen server connected to the client, the client generates second encrypted data by using a command encrypt data2, namely AES. And finally, obtaining an encrypted encryptData2 result, wherein the encryptData2 is second encrypted data generated by the client by adopting an AES encryption algorithm.
Then, the second information to be verified is generated by a command Key3, which is md5.create (encryptData2), and the command obtains the second information to be verified Key3 by calling the MD5 algorithm.
When the client connects to the bullet screen server, the client carries the reported second information Key3 to be verified and the second identity information. And after receiving the information reported by the client, the bullet screen server generates second verification information Key4 by adopting the same encryption algorithm based on the second identity information and the second Key in the same way. Continuing with the above example, the bullet screen server also generates second encrypted data by using an AES encryption algorithm based on version number information version of the client, client type information clienttype, device unique ID (i.e., device identification) of the client, and timestamp information time2 of the current connection, and then calculates second verification information Key4 by using an MD5 encryption algorithm.
Furthermore, if the client is a legal client, the second verification information Key4 generated by the bullet screen server is consistent with the second information Key3 to be verified reported by the legal client, and it can be determined that the matching is successful, so that the client can pass the verification of the bullet screen server, and the bullet screen server responds to the connection request of the client to establish the connection with the client.
Further, in this embodiment, in order to increase the speed at which the client successfully connects to the bullet screen server, the method in this embodiment may further be implemented by, in a case that the preset application is a live broadcast platform, the following steps:
connecting to a gateway server under the condition that the live broadcast platform is detected to start a barrage function and enters a first live broadcast room;
acquiring a first candidate barrage server list sent by the gateway server;
acquiring a historical connection record of a barrage server corresponding to the first live broadcast room, wherein the historical connection record of the barrage server comprises a record of the barrage server connected during the live broadcast platform entering the first live broadcast room within a first preset time range;
and connecting the bullet screen servers in the first candidate bullet screen server list according to a preset strategy based on the historical connection records of the bullet screen servers.
Specifically, in this embodiment, the following conditions may trigger the client to connect to the bullet screen server: first, after the live broadcast platform starts, if the live broadcast platform starts the barrage function, the user clicks to enter a first live broadcast room at the moment, and the client is triggered to connect the barrage server. And secondly, after the live broadcast platform is started, a user clicks to enter a first live broadcast room, the user starts a bullet screen function during watching the first live broadcast room, and the client is triggered to be connected with a bullet screen server.
Furthermore, when the client connects to the bullet screen server, the client first needs to connect to the gateway server, and the process of connecting to the gateway server has been described in detail in the foregoing embodiments, which is not described in detail herein.
Further, in this embodiment, before the client is connected to the gateway server, the live broadcast platform enters into at every time under the condition that the barrage server is connected to the first live broadcast room, if the connection is successful, the record and the first live broadcast room corresponds to the connection success record of the barrage server, if the connection is failed, the record and the first live broadcast room corresponds to the connection failure record of the barrage server, so as to form a barrage server history connection record corresponding to the first live broadcast room.
Specifically, the client records the record of the live broadcast platform entering the first live broadcast room connection barrage server each time, including the connection success record and the connection failure record. The live broadcast platform is opening under the bullet screen function condition, gets into all can connect bullet screen server between the first stull at every turn, according to aforementioned bullet screen server connected mode, can select bullet screen server from the candidate list and connect until connecting successfully. Such as: when the bullet screen server 1 is successfully connected when the user enters the first live broadcast room at the moment 1, the record of the successful connection is recorded, and the record includes information such as the ID of the first live broadcast room, a successful connection identifier (which is used for indicating that the connection is successful, and can be represented by "1"), the time length consumed by the successful connection, the connection moment, the successfully connected bullet screen server ID, the IP address, the port number and the like. When entering the first live broadcast room at the time2, the connection of the bullet screen server 2 fails, and records the record of the failed connection, including the ID of the first live broadcast room, the failed connection identifier (which is used to indicate that the connection fails, and may be represented by "0"), the connection time, the bullet screen server ID of the connection failure, the IP address, the port number, and other information. In this way, a bullet screen server historical connection record corresponding to the first live broadcast room can be formed.
Furthermore, after the first candidate barrage server list is received, a record of the barrage server entering the first direct broadcasting time period within a first preset time range can be screened from historical connection records of the barrage server corresponding to the first direct broadcasting time. Such as: and screening out historical connection records of the bullet screen server corresponding to the first direct broadcasting time within the closest 24 hours from the current time. Based on the above-mentioned mode of record, can be based on first live broadcast ID and connect the moment and screen the result fast.
Furthermore, the bullet screen servers in the first candidate bullet screen server list can be connected according to a preset strategy based on the record of entering the first direct broadcasting time period within the first preset time range, and the method can be specifically realized through the following steps:
based on the historical connection records of the bullet screen servers, obtaining connection success records and connection failure records of each bullet screen server in the first candidate bullet screen server list within the first preset time range;
obtaining a connection success rate of each bullet screen server based on a connection success record and a connection failure record of each bullet screen server in the first candidate bullet screen server list within the first preset time range;
and connecting the bullet screen servers in the first candidate bullet screen server list according to the sequence of the power from high to low until the connection is successful.
Specifically, the first candidate barrage server list comprises a plurality of barrage servers, and based on historical connection records of the barrage servers, a connection success record and a connection failure record of each barrage server in the first candidate barrage server list within a first preset time range can be obtained. Such as: the first candidate barrage server list comprises a barrage server 1, a barrage server 2 and a barrage server 3, and based on historical connection records of the barrage server, records of successful and failed connection of the barrage server 1 corresponding to the live broadcast room 1 within 24 hours closest to the current time can be obtained, wherein the number of successful connection is N1, and the number of failed connection is N2. And recording the IP address 2 of the bullet screen server 2 in the latest 24 hours from the current time, wherein the number of successful connections is N3, and the number of failed connections is N4, and the number of successful and failed connections corresponds to the live broadcast room 1. And recording the IP address 3 of the successful and failed connection barrage server 3 corresponding to the live broadcast room 1 within the last 24 hours from the current time, wherein the number of successful connections is N5, and the number of failed connections is N6.
Through the history connection records, it can be determined that the success rate of the client connecting to the bullet screen server 1 is N1/(N1+ N2+ N3+ N4+ N5+ N6), the success rate of the client connecting to the bullet screen server 2 is N3/(N1+ N2+ N3+ N4+ N5+ N6), and the success rate of the client connecting to the bullet screen server 3 is N5/(N1+ N2+ N3+ N4+ N5+ N6). Of course, the success rate of connecting each bullet screen server can also be defined in other ways, such as: continuing with the above example, the success rate of the client connecting to the bullet screen server 1 is defined as N1-N2, the success rate of the client connecting to the bullet screen server 2 is defined as N3-N4, and the success rate of the client connecting to the bullet screen server 3 is defined as N5-N6. In a specific implementation process, the success rate of connecting the client to each bullet screen server can be defined according to actual needs, and the application is not limited herein. And then, the bullet screen servers in the first candidate bullet screen server list can be sequentially connected according to the sequence of the connection power from high to low until the connection is successful.
Since the first candidate bullet screen server list includes the domain name address, the method in this embodiment may perform connection in the foregoing domain name resolution manner, for example: continuing with the above example, if the success rate is ranked from high to low, the bullet screen server 1, the bullet screen server 3, and the bullet screen server 2 are arranged. The method comprises the steps of firstly connecting the bullet screen server 1, analyzing an IP address and a port number corresponding to the bullet screen server 1, and then connecting based on the analyzed IP address and the analyzed port number. When the connection of the bullet screen server 1 fails, the bullet screen server 3 is connected again, and when the connection of the bullet screen server 3 fails, the bullet screen server 2 is connected again.
Further, if all the bullet screen servers in the first candidate bullet screen server list fail to connect, as can be seen in the foregoing embodiment, the gateway server may also issue a second bullet screen server list including the guaranteed-base IP address and the port number. Similarly, the client can call a bullet screen server connection record corresponding to the first live broadcast within a second preset time range, determine the connection power of each bullet screen server in the second bullet screen server list based on the record, and finally connect the bullet screen servers in the second candidate bullet screen server list in the sequence from high power to low power until the connection is successful.
Such as: the second candidate barrage server list includes the barrage server 1, the barrage server 5, and the barrage server 7, and based on the historical connection records of the barrage server, the records of the IP address 1 of the successful and failed connection barrage server 1 corresponding to the live broadcast room 1 in the last 24 hours from the current time can be obtained, where the number of successful connections is N11, and the number of failed connections is N12. And recording the IP address 5 of the bullet screen server 5 in the latest 24 hours from the current time, wherein the number of successful connections is N31, and the number of failed connections is N41, and the number of successful and failed connections corresponds to the live broadcast room 1. And recording the IP address 7 of the successful and failed connection barrage server 7 corresponding to the live broadcast room 1 within the last 24 hours from the current time, wherein the number of successful connections is N51, and the number of failed connections is N61.
Through the history connection records, it can be determined that the success rate of the client connecting to the bullet screen server 1 is N11/(N11+ N21+ N31+ N41+ N51+ N61), the success rate of the client connecting to the bullet screen server 5 is N31/(N11+ N21+ N31+ N41+ N51+ N61), and the success rate of the client connecting to the bullet screen server 6 is N51/(N11+ N21+ N31+ N41+ N51+ N61). Of course, the success rate of connecting each bullet screen server can also be defined in other ways, such as: continuing with the above example, the success rate of the client connecting to the bullet screen server 1 is defined as N11-N21, the success rate of the client connecting to the bullet screen server 5 is defined as N31-N41, and the success rate of the client connecting to the bullet screen server 7 is defined as N51-N61. In a specific implementation process, the success rate of connecting the client to each bullet screen server can be defined according to actual needs, and the application is not limited herein. And then, the bullet screen servers in the second candidate bullet screen server list can be sequentially connected according to the sequence of the connection power from high to low until the connection is successful.
Continuing with the above example, if the success rate is ranked from high to low, the bullet screen server 1, the bullet screen server 5, and the bullet screen server 7 are arranged. The method comprises the steps of firstly connecting the bullet screen server 1, then connecting the bullet screen server 5 when the connection of the bullet screen server 1 fails, and then connecting the bullet screen server 7 when the connection of the bullet screen server 5 fails.
Further, if all the bullet screen servers in the second candidate bullet screen server list are failed to connect, a bullet screen server based on an HTTP protocol can be connected. The manner of connecting the bullet screen server based on the HTTP protocol has been described in detail in the foregoing embodiments, and details are not described herein.
Further, in this embodiment, predetermine the application and be the live platform, can also predict the live room that this user probably will get into when the user gets into the live platform, and then, connect corresponding barrage server in advance before getting into this live room, like this, just can in time carry out the receiving and dispatching of barrage information when getting into the live room. Specifically, the method can be realized by the following steps:
under the condition that the client is detected to start the live broadcast platform and the live broadcast platform starts a barrage function, acquiring at least one live broadcast room concerned by a user logging in the live broadcast platform;
determining a first live broadcast room from the at least one live broadcast room, and acquiring a first candidate barrage server list corresponding to the first live broadcast room;
and connecting the bullet screen servers in the first candidate bullet screen server list according to a preset strategy so that the live broadcast platform is successfully connected with the bullet screen servers before entering the first live broadcast room.
Specifically, in this embodiment, after the user logs in the live broadcast platform through the account password, the user firstly enters the main function interface of the live broadcast platform, at this time, the client acquires at least one live broadcast room concerned by the user, and since the user concerns the live broadcast room and indicates that the user is interested in the live broadcast video of the live broadcast room, the user is most likely to enter the concerned live broadcast room. Therefore, the client side can determine a first live broadcast room which is most likely to be entered by the user based on the historical viewing record of the user or the information of the live broadcast room, and specifically, the mode for determining the first live broadcast room can be realized through the following modes:
the first method comprises the following steps: acquiring the live broadcast time corresponding to each live broadcast room in the at least one live broadcast room; and determining a live broadcast room closest to the current time of the live broadcast time from the at least one live broadcast room as a first live broadcast room.
Specifically, in this embodiment, after the client acquires the multiple live broadcast rooms focused by the user, since each live broadcast room generally has a fixed play time, when determining the first live broadcast room that the user is most likely to enter, it may be determined that the play time is the first live broadcast room closest to the current time from the multiple live broadcast rooms focused by the user. Further, if the determined time interval between the playing time of the first live broadcast and the current time is greater than a preset time interval (for example, 10 minutes, 20 minutes, and the like), the policy of pre-connecting the bullet screen server may be abandoned, and only if the determined time interval between the playing time of the first live broadcast and the current time is less than or equal to the preset time interval, the subsequent steps may be executed.
And the second method comprises the following steps: acquiring a historical watching record of the user watching the at least one live broadcast room within a preset time range; and determining the live broadcast room with the most watching times from the at least one live broadcast room as a first live broadcast room based on the historical watching records.
Specifically, in this embodiment, after the client acquires the multiple live broadcast rooms focused on by the user, the history viewing records of the multiple live broadcast rooms focused on by the user in the preset time range can be viewed, for example: the records of the concerned live broadcast rooms are watched in the week closest to the current time, and then the live broadcast room with the largest watching times can be determined from the concerned live broadcast rooms of the user as the first live broadcast room. Further, if the determined time interval between the playing time of the first live broadcast and the current time is greater than a preset time interval (for example, 10 minutes, 20 minutes, and the like), at this time, the viewing times may be selected to be ranked at least in the second live broadcast as the first live broadcast, and if the determined time interval between the playing time of the first live broadcast and the current time is less than or equal to the preset time interval, it is determined that the determined first live broadcast is correct, and the subsequent steps are executed.
Further, after the first direct broadcasting time is determined, the first direct broadcasting time may be connected to the gateway server first, and then connected to the bullet screen server through the gateway server. When the gateway server issues the first candidate barrage server list, the barrage servers in the first candidate barrage server list are required to correspond to the first live broadcast room, specifically, each live broadcast room is provided with a barrage server capable of being connected to, when the client sends a connection request to the gateway server, the client can send identification information of the first live broadcast room to the gateway server, and the gateway server can quickly determine the first candidate barrage server list corresponding to the client according to the identification information of the first live broadcast room. Similarly, when the first candidate barrage server list fails to be connected, the gateway server can also quickly determine a second candidate barrage server list corresponding to the first candidate barrage server list based on the identification information of the first live broadcast room. And then the bullet screen server is connected by adopting any mode in the previous embodiment.
Further, in this embodiment, the connection may also be performed based on a historical connection record, such as: can determine the bullet screen server that the latest successful connection that first live broadcast room corresponds connects, perhaps determine the bullet screen server that the number of times of successful connection is the most from the bullet screen server connection record that first live broadcast room corresponds in last a week and connect, at the concrete implementation in-process, can come the tactics of making the connection according to actual need, here, this application does not do the restriction. Because the client is connected to the corresponding barrage server in advance before the live broadcast platform enters the first live broadcast room, the barrage information can be displayed and sent in time when the client actually enters the first live broadcast room.
Referring to fig. 2, a second embodiment of the present invention provides a bullet screen server connection method, which is applied to a bullet screen server system, where the bullet screen server system includes a plurality of gateway servers and a plurality of bullet screen servers, and the method includes:
s201: the method comprises the steps that under the condition that a first connection request sent by a client is received by a gateway server, a first candidate barrage server list is sent to the client in response to the first connection request, and the first candidate barrage server list comprises domain name addresses of at least one barrage server;
s202: if the gateway server receives information that the connection of the client fails for all the bullet screen servers in the first candidate bullet screen server list, sending a second candidate bullet screen server list to the client, wherein the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in at least one bullet screen server;
s203: and if the client determines the connected bullet screen server based on the second candidate bullet screen server list, the bullet screen server responds to a second connection request sent by the client under the condition that the bullet screen server receives the second connection request, and the connection with the client is established.
Specifically, the bullet screen connection method applied to the bullet screen server system provided in this embodiment has been described in detail in the first embodiment, and is not described herein again.
In this embodiment, a method for maintaining a bullet screen server is further provided, and is applied to the bullet screen server system, including:
acquiring bullet screen server connection information fed back by each client in a plurality of clients each time the client is connected with a bullet screen server;
counting the connection information of each bullet screen server in the plurality of bullet screen servers within a preset time range according to a preset time interval;
determining an invalid bullet screen server from the plurality of bullet screen servers based on the connection information of each bullet screen server within a preset time range;
and repairing the invalid bullet screen server.
Specifically, in this embodiment, the client performs connection recording of the bullet screen server every time when connecting the bullet screen server, for example: if the client successfully connects to the barrage server, the record of the successful connection is recorded, including the ID of the client, the successful connection identifier (which may be represented by "1" to indicate that the connection is successful), the time consumed by the successful connection, the connection time, the ID of the barrage server successfully connected, the IP address and the port number, and if the preset application program is a live broadcast application program, the ID of the live broadcast room where the preset application program is located at this time is also recorded. If the client fails to connect the barrage server, the record of the failed connection is recorded, including the ID of the client, the failed connection identifier (which is used to indicate the connection failure, and may be represented by "0"), the connection time, the barrage server ID of the connection failure, the IP address, the port number, and other information, and if the preset application program is a live broadcast application program, the ID of the live broadcast room where the preset application program is located is also recorded.
Furthermore, each client of the whole network carries out the connection record of the bullet screen server when connecting the bullet screen server every time, stores the record locally and uploads the record to the bullet screen server system, and the client can be an information collection device for managing all bullet screen servers in the bullet screen server system and can carry the connection information of the bullet screen server through HTTP request. Furthermore, after the information collection device receives the connection information reported by each client, each connection is classified into a corresponding bullet screen server, for example: if the client 1 successfully connects with the successful connection record 1 of the bullet screen server 1 at the moment 1 and the client 2 successfully connects with the successful connection record 2 of the bullet screen server 1 at the moment 2, the successful connection record 1 and the successful connection record 2 are classified into the connection record of the bullet screen server 1. In this way, the bullet screen server system can form a connection record for each bullet screen server.
Furthermore, the method in this embodiment may count the connection information of each bullet screen server in a preset time range according to a preset time interval (1 hour, 3 hours, 5 hours, etc.), where the connection information includes the connection success frequency and the connection failure frequency of each bullet screen server in the preset time range, for example: and counting the corresponding connection success times and connection failure times of each bullet screen server within the closest 5 hours from the current time every 5 hours.
Furthermore, an invalid bullet screen server can be determined from the plurality of bullet screen servers based on the connection information of each bullet screen server within a preset time range, and specifically, the method can be realized through the following steps:
determining the connection power of each bullet screen server based on the connection success times and the connection failure times of each bullet screen server in the preset time range; and determining the bullet screen server with the connection success rate smaller than the preset connection success rate as an invalid bullet screen server.
Specifically, in this embodiment, after the successful connection times and the failed connection times of each bullet screen server within the preset time range are obtained, the connection success rate of each bullet screen server can be determined, specifically, the connection success rate is the quotient of the successful connection times and the total connection times, and the total connection times is the sum of the successful connection times and the failed connection times. Such as: the number of successful connections of the bullet screen server 1 in the preset time range is N1, the number of failed connections is N2, and the connection success rate of the bullet screen server 1 is N1/(N1+ N2). Of course, other ways to define the connected power may be used, and the application is not limited herein.
And then, after the corresponding connection power of each bullet screen server is determined, the bullet screen server with the connection power smaller than the preset connection success rate can be determined to be an invalid bullet screen server. Specifically, in this embodiment, the preset time interval, the preset time unit, and the preset connection power can be set according to actual needs, and the present application is not limited herein.
Further, in this implementation, the invalid bullet screen server may also be determined in other manners, such as: and determining the bullet screen server with the continuous failure connection times larger than the preset times as an invalid bullet screen server. The mode of determining the invalid bullet screen server can be set according to actual needs, and the method is not limited in the application.
Furthermore, after the invalid bullet screen server is determined, the bullet screen server system can also send the determined identifier of the invalid bullet screen server to each client, so that the client shields the invalid bullet screen server when being connected with the bullet screen server, only the valid bullet screen server is connected, and the connection speed is improved.
Further, the client locally records related information of each connection of the bullet screen server, if the connection power is smaller than a preset success rate or the connection frequency of continuous failure is larger than a preset frequency for the first bullet screen server, the client also confirms that the first bullet screen server is an invalid bullet screen server, then the client can directly report the information that the first bullet screen server is the invalid bullet screen server to the bullet screen server system, and the bullet screen server system determines the first bullet screen server as the invalid bullet screen server after receiving the information. When the client is connected, the first barrage server is shielded.
Furthermore, after the invalid bullet screen server is determined in the above manner, the bullet screen server system may also repair the invalid bullet screen server, specifically, repair the corresponding domain name address, IP address, port, and the like. After the restoration is completed, the related bullet screen connection information of the invalid bullet screen server is initialized, and a notification is sent to the client so that the client initializes the related records of the restored invalid bullet screen server, and the restored bullet screen server does not need to be shielded in the subsequent connection.
Further, when the bullet screen servers are connected, as can be seen from the foregoing embodiment, the gateway server needs to send a candidate list of bullet screen servers, including a first candidate list of bullet screen servers and a second candidate list of bullet screen servers, after receiving a connection request from the client, and when determining a bullet screen server in the candidate list of bullet screen servers, because each time each bullet screen server is successfully connected to a corresponding bullet screen server, the connection duration is also included in the corresponding connection information of the bullet screen server, so that the client can connect to the bullet screen server more quickly, the method in this embodiment may further determine the bullet screen server in the candidate list of bullet screen server by:
determining the average connection duration for successfully connecting each bullet screen server based on the connection duration of each bullet screen server in each connection within the preset time range; under the condition of receiving a connection request of a client for connecting a bullet screen server, determining a candidate bullet screen server list based on the average connection duration of each bullet screen server; and sending the candidate barrage server list to the client so that the client is connected with a barrage server based on the candidate barrage server.
Wherein, the determining a list of candidate bullet screen server based on the average connection duration of each bullet screen server comprises: and determining the bullet screen server with the average connection time length less than the preset time length as a server in the candidate bullet screen server list.
Specifically, in this embodiment, each time the client successfully connects to the bullet screen server, the client has corresponding connection information, which includes the connection duration for successfully connecting to the bullet screen server, so that the bullet screen server system can obtain the average connection duration corresponding to the successful connection of each bullet screen server within the preset time range. Such as: in 1 hour, the time length for the client 1 to successfully connect with the barrage server 1 is T1, the time length for the client 2 to successfully connect with the barrage server 1 is T2, and the time length for the client 3 to successfully connect with the barrage server 1 is T3, so that the average connection time length for the barrage server 1 in 1 hour is (T1+ T2+ T3)/3. Furthermore, when the candidate bullet screen device server list is determined, a bullet screen server with the average connection duration less than the preset duration can be selected as a server in the candidate bullet screen device server list. Of course, when determining the list of candidate bullet screen servers, the load condition and the port occupation condition of the bullet screen servers or other information need to be considered comprehensively, and in the specific implementation process, the manner of determining the list of candidate bullet screen servers may be set according to actual needs, which is not limited in this application.
Furthermore, the bullet screen server system sends the determined candidate bullet screen device server list to the client, and the client performs bullet screen server connection based on the received candidate bullet screen device server list.
Referring to fig. 3, a third embodiment of the present invention provides a client, including:
the first connection unit 301 is configured to connect to a gateway server when detecting that a preset application program starts a barrage function;
a first obtaining unit 302, configured to obtain a first candidate bullet screen server list sent by the gateway server, where the first candidate bullet screen server list includes a domain name address of at least one bullet screen server;
a second connection unit 303, configured to connect, according to a first preset policy, the bullet screen servers in the first candidate bullet screen server list;
a second obtaining unit 304, configured to obtain a second candidate bullet screen server list if all bullet screen servers in the first candidate bullet screen server list are failed to connect, where the second candidate bullet screen server list includes an IP address and a port number of each bullet screen server in at least one bullet screen server;
a third connecting unit 305, configured to connect the bullet screen servers in the second candidate bullet screen server list according to a second preset policy.
Further, the second connection unit is configured to:
and selecting one bullet screen server from the first candidate bullet screen server list in sequence at random for connection until the connection is successful or the bullet screen servers in the first candidate bullet screen server list are all failed to be connected.
Further, the second connection unit is configured to:
sequentially and randomly selecting one bullet screen server from the first candidate bullet screen server list to obtain the domain name address of the randomly selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the randomly selected bullet screen server;
and connecting the randomly selected bullet screen server based on the IP address and the port number of the randomly selected bullet screen server.
Further, the third connection unit is configured to:
and selecting one bullet screen server from the second candidate bullet screen server list in sequence at random for connection until the connection is successful.
Further, the third connection unit is configured to:
sorting the bullet screen servers in the second candidate bullet screen server list according to the connection power from high to low;
and sequentially connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the connection power from high to low until the connection is successful.
Further, the client further comprises:
and the fourth connecting unit is used for connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy and then connecting the bullet screen servers based on the HTTP protocol if the bullet screen servers in the second candidate bullet screen server list are failed to connect.
Referring to fig. 4, a fourth embodiment of the present invention provides a client, including: a processor 401, a memory 402, and a computer program stored in the memory and executable on the processor, for example, a program corresponding to the bullet screen server connection method in the first embodiment. The processor implements the steps of the bullet screen server connection method in the first embodiment when executing the computer program. Alternatively, the processor implements the functions of the modules/units in the client according to the third embodiment when executing the computer program.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program in the computer apparatus. For example, the computer program may be divided into functions of a first connection unit, a first acquisition unit, a second connection unit, a second acquisition unit, and a third connection unit, and the specific functions of each unit are as follows:
the first connection unit is used for connecting to the gateway server under the condition that the preset application program is detected to start the barrage function;
the first acquisition unit is used for acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list comprises domain name addresses of at least one barrage server;
the second connection unit is used for connecting the bullet screen servers in the first candidate bullet screen server list according to a first preset strategy;
a second obtaining unit, configured to obtain a second candidate bullet screen server list if all bullet screen servers in the first candidate bullet screen server list are failed to connect, where the second candidate bullet screen server list includes an IP address and a port number of each bullet screen server in at least one bullet screen server;
and the third connecting unit is used for connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy.
The server may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that the schematic diagram 4 is merely an example of a computer apparatus and is not intended to limit a server, which may include more or fewer components than those shown, or some components in combination, or different components, for example, the server may also include input output devices, network access devices, buses, etc.
The Processor 401 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like which is the control center for the computer device and which connects the various parts of the overall computer device using various interfaces and lines.
The memory 402 may be used to store the computer programs and/or modules, and the processor may implement the various functions of the computer device by running or executing the computer programs and/or modules stored in the memory, as well as by invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
A fifth embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored, and the client-side integrated functional unit in the third embodiment of the present invention, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in one computer-readable storage medium. Based on such understanding, all or part of the processes in the bullet screen server connection method in the first embodiment and the second embodiment of the present invention may also be implemented by a computer program instructing related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the above method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
In the technical scheme of the embodiment of the invention, the bullet screen server system comprises the gateway server and the bullet screen server, the functions required to be completed by the gateway server are fewer, and the client can be easily connected with the gateway server. Under the condition that the client starts the bullet screen function of the preset application program, the client is firstly connected with the gateway server, and after a first candidate bullet screen server list issued by the gateway server is received, the IP address and the port number of the bullet screen server are obtained by analyzing the domain name address in the first candidate bullet screen server list. The IP address of the barrage server cannot be acquired due to the fact that the DNS is hijacked, or the acquired IP address is not connected with the barrage server. If all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, the technical scheme in the embodiment of the invention also can issue a second candidate bullet screen server list through the gateway server, the second candidate bullet screen server list comprises the IP address and the port number of the bullet screen server, and the client can be directly connected with the bullet screen servers in the second candidate bullet screen server list based on the IP address and the port number, so that the success rate of the client in connecting with the bullet screen servers can be effectively improved.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A bullet screen server connection method is applied to a client side and is characterized by comprising the following steps:
under the condition that the preset application program is detected to start the bullet screen function, the method is connected to the gateway server and comprises the following steps: when a client is connected with a gateway server, pulling an IP list of a candidate gateway server from a PHP server through an HTTP request, selecting the IP address and port of the gateway server with less load to form the IP list of the candidate gateway server by the PHP server according to the load condition of a connection client of each gateway server in the whole network, issuing the determined IP list of the gateway server to the client by the PHP server, obtaining the IP list of the gateway server from the PHP server by the client, then randomly selecting one IP and port for connection each time by adopting a random strategy, finishing the connection step of the gateway server if the connection is carried out, or randomly selecting the rest of the IP and ports from the IP list of the gateway server again for connection until the gateway server is successfully connected;
acquiring a first candidate barrage server list sent by the gateway server, wherein the first candidate barrage server list is determined by the gateway server according to the load condition and the geographic position of each barrage server, and the first candidate barrage server list comprises the domain name address of at least one barrage server;
performing domain name address resolution on a domain name address according to a first preset strategy, and connecting the bullet screen servers in the first candidate bullet screen server list based on the IP address and the port number obtained by resolution;
if all the bullet screen servers in the first candidate bullet screen server list are failed to connect, acquiring a second candidate bullet screen server list, wherein the second candidate bullet screen server list is determined by a gateway server according to the load condition and the port occupation condition of each bullet screen server, and the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in the bullet screen servers directly sent to a client by at least one gateway server;
and connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy based on the IP address and the port number of each bullet screen server in the second candidate bullet screen server list.
2. The method of claim 1, wherein said connecting the bullet screen servers in the first list of candidate bullet screen servers according to a first preset policy comprises:
and selecting one bullet screen server from the first candidate bullet screen server list in sequence at random for connection until the connection is successful or the bullet screen servers in the first candidate bullet screen server list are all failed to be connected.
3. The method of claim 2, wherein the randomly selecting one of the bullet screen servers in sequence from the first list of candidate bullet screen servers for connection comprises:
sequentially and randomly selecting one bullet screen server from the first candidate bullet screen server list to obtain the domain name address of the randomly selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the randomly selected bullet screen server;
and connecting the randomly selected bullet screen server based on the IP address and the port number of the randomly selected bullet screen server.
4. The method of claim 1, wherein said connecting the bullet screen servers in the second list of candidate bullet screen servers according to a second predetermined policy comprises:
and selecting one bullet screen server from the second candidate bullet screen server list in sequence at random for connection until the connection is successful.
5. The method of claim 1, wherein said connecting the bullet screen servers in the second list of candidate bullet screen servers according to a second predetermined policy comprises:
sorting the bullet screen servers in the second candidate bullet screen server list according to the connection power from high to low;
and sequentially connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the connection power from high to low until the connection is successful.
6. The method of claim 1, wherein after said connecting the bullet screen servers in the second list of candidate bullet screen servers according to the second preset policy, the method further comprises:
and if all the bullet screen servers in the second candidate bullet screen server list are failed to be connected, connecting the bullet screen servers based on the HTTP protocol.
7. A bullet screen server connection method is applied to a bullet screen server system, and is characterized in that the bullet screen server system comprises a plurality of gateway servers and a plurality of bullet screen servers, and the method comprises the following steps:
under the condition that the preset application program is detected to start the bullet screen function, the method is connected to the gateway server and comprises the following steps: when a client is connected with a gateway server, pulling an IP list of a candidate gateway server from a PHP server through an HTTP request, selecting the IP address and port of the gateway server with less load to form the IP list of the candidate gateway server by the PHP server according to the load condition of a connection client of each gateway server in the whole network, issuing the determined IP list of the gateway server to the client by the PHP server, obtaining the IP list of the gateway server from the PHP server by the client, then randomly selecting one IP and port for connection each time by adopting a random strategy, finishing the connection step of the gateway server if the connection is carried out, or randomly selecting the rest of the IP and ports from the IP list of the gateway server again for connection until the gateway server is successfully connected;
the method comprises the steps that the gateway server responds to a first connection request sent by a client and sends a first candidate barrage server list to the client under the condition that the gateway server receives the first connection request, the first candidate barrage server list is determined by the gateway server according to the load condition and the geographic position of each barrage server, the first candidate barrage server list comprises domain names of at least one barrage server, the client performs domain name address resolution on the domain names according to a first preset strategy, and the barrage servers in the first candidate barrage server list are connected based on the resolved IP addresses and port numbers;
if the gateway server receives information that the connection of the client to all the bullet screen servers in the first candidate bullet screen server list fails, sending a second candidate bullet screen server list to the client, wherein the second candidate bullet screen server list is determined by the gateway server according to the load condition and the port occupation condition of each bullet screen server, and the second candidate bullet screen server list comprises the IP address and the port number of each bullet screen server in the bullet screen servers directly sent to the client by at least one gateway server;
and if the client determines the connected bullet screen servers based on the second candidate bullet screen server list, the bullet screen servers respond to the second connection request under the condition that the second connection request sent by the client is received, and connection with the client is established based on the IP address and the port number of each bullet screen server in the second candidate bullet screen server list.
8. A client, comprising:
the first connection unit is used for connecting to the gateway server when detecting that the preset application program opens the barrage function, and comprises: when a client is connected with a gateway server, pulling an IP list of a candidate gateway server from a PHP server through an HTTP request, selecting the IP address and port of the gateway server with less load to form the IP list of the candidate gateway server by the PHP server according to the load condition of a connection client of each gateway server in the whole network, issuing the determined IP list of the gateway server to the client by the PHP server, obtaining the IP list of the gateway server from the PHP server by the client, then randomly selecting one IP and port for connection each time by adopting a random strategy, finishing the connection step of the gateway server if the connection is carried out, or randomly selecting the rest of the IP and ports from the IP list of the gateway server again for connection until the gateway server is successfully connected;
the first acquisition unit is used for acquiring a first candidate bullet screen server list sent by the gateway server, wherein the first candidate bullet screen server list is determined by the gateway server according to the load condition and the geographic position of each bullet screen server, and the first candidate bullet screen server list comprises the domain name address of at least one bullet screen server;
the second connection unit is used for carrying out domain name address resolution on the domain name address according to a first preset strategy, and connecting the bullet screen servers in the first candidate bullet screen server list based on the IP address and the port number obtained by resolution;
a second obtaining unit, configured to obtain a second candidate bullet screen server list if all bullet screen servers in the first candidate bullet screen server list are failed to connect, where the second candidate bullet screen server list is determined by a gateway server according to a load condition and a port occupation condition of each bullet screen server, and the second candidate bullet screen server list includes an IP address and a port number of each bullet screen server in bullet screen servers that are directly sent to a client by at least one gateway server;
and the third connecting unit is used for connecting the bullet screen servers in the second candidate bullet screen server list according to a second preset strategy based on the IP address and the port number of each bullet screen server in the second candidate bullet screen server list.
9. A client, characterized in that the client comprises a processor for implementing the steps of the bullet screen server connection method as claimed in claims 1-6 when executing a computer program stored in a memory.
10. A readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the bullet screen server connection method according to any one of claims 1 to 7.
CN201810293884.2A 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium Active CN108366277B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810293884.2A CN108366277B (en) 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810293884.2A CN108366277B (en) 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium

Publications (2)

Publication Number Publication Date
CN108366277A CN108366277A (en) 2018-08-03
CN108366277B true CN108366277B (en) 2021-06-15

Family

ID=63002141

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810293884.2A Active CN108366277B (en) 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium

Country Status (1)

Country Link
CN (1) CN108366277B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108696831B (en) * 2018-09-03 2022-02-01 万惠投资管理有限公司 Short message sending method and device
CN109275014B (en) * 2018-09-13 2021-09-07 武汉斗鱼网络科技有限公司 Bullet screen linking method and mobile terminal
CN110971923B (en) * 2018-09-30 2021-11-09 武汉斗鱼网络科技有限公司 Bullet screen connection method, storage medium, system and client
CN110418176B (en) * 2018-11-05 2021-12-14 腾讯科技(深圳)有限公司 Barrage information processing method and device, server and storage medium
CN110139163B (en) * 2019-05-22 2021-06-22 武汉瓯越网视有限公司 Method and related device for acquiring bullet screen
CN111414208B (en) * 2020-03-13 2023-08-01 百度在线网络技术(北京)有限公司 Application program starting method, device and equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070113600A (en) * 2006-05-25 2007-11-29 (주)씨디네트웍스 Server connection system and load balancing network system
CN102340554A (en) * 2011-09-29 2012-02-01 奇智软件(北京)有限公司 Optimal application server selection method and device for domain name system (DNS)
CN102790808A (en) * 2011-05-16 2012-11-21 奇智软件(北京)有限公司 Domain name resolution method and system, client
CN103957283A (en) * 2011-09-29 2014-07-30 北京奇虎科技有限公司 Optimal-application-server selection method and device for domain name system
CN104065761A (en) * 2011-09-29 2014-09-24 北京奇虎科技有限公司 Application server selecting method and network connection method
CN104158919A (en) * 2014-08-20 2014-11-19 安一恒通(北京)科技有限公司 Webpage access implementation method, server and client
CN105871977A (en) * 2015-11-27 2016-08-17 乐视体育文化产业发展(北京)有限公司 Long connection establishment method and system, and devices
CN107547484A (en) * 2016-06-29 2018-01-05 上海连尚网络科技有限公司 Message obtains, method, equipment and the system of push

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150149524A1 (en) * 2013-11-27 2015-05-28 Sharp Kabushiki Kaisha Network system, constant connection method, electronic device, server, and program
US9603003B2 (en) * 2014-03-05 2017-03-21 Google Technology Holdings LLC Methods and apparatus for radio network scanning using geo-tagged information from wireless client devices of heterogeneous wide area networks
GB2549536B (en) * 2016-04-22 2020-12-02 Orbital Multi Media Holdings Corp Media data streaming method and apparatus

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070113600A (en) * 2006-05-25 2007-11-29 (주)씨디네트웍스 Server connection system and load balancing network system
CN102790808A (en) * 2011-05-16 2012-11-21 奇智软件(北京)有限公司 Domain name resolution method and system, client
CN102340554A (en) * 2011-09-29 2012-02-01 奇智软件(北京)有限公司 Optimal application server selection method and device for domain name system (DNS)
CN103957283A (en) * 2011-09-29 2014-07-30 北京奇虎科技有限公司 Optimal-application-server selection method and device for domain name system
CN104065761A (en) * 2011-09-29 2014-09-24 北京奇虎科技有限公司 Application server selecting method and network connection method
CN104158919A (en) * 2014-08-20 2014-11-19 安一恒通(北京)科技有限公司 Webpage access implementation method, server and client
CN105871977A (en) * 2015-11-27 2016-08-17 乐视体育文化产业发展(北京)有限公司 Long connection establishment method and system, and devices
CN107547484A (en) * 2016-06-29 2018-01-05 上海连尚网络科技有限公司 Message obtains, method, equipment and the system of push

Also Published As

Publication number Publication date
CN108366277A (en) 2018-08-03

Similar Documents

Publication Publication Date Title
CN108366277B (en) Bullet screen server connection method, client and readable storage medium
CN110213522B (en) Video data processing method and device and related equipment
CN111260398B (en) Advertisement putting control method and device, electronic equipment and storage medium
WO2021233048A1 (en) Blockchain-based data detection method and device, and computer-readable storage medium
CN110324296B (en) Bullet screen server connection method and device and client
CN107801059B (en) A kind of method for authenticating and server
US20210160294A1 (en) Methods, devices, and systems for live video streaming from a remote location based on a received request utilizing keep alive messages
CN105872640A (en) Live broadcast video obtaining method, device and system
US20160173686A1 (en) Method, system and electronic device for remotely recording and authenticating associated recorded files
CN108023727B (en) Authorization method and system thereof
CN107426253B (en) Data verification method and client
WO2019061626A1 (en) Data verification method, and server
WO2019061628A1 (en) Data verification method, and server
EP3391608B1 (en) Handling of content delivery in a client node
CN106412498A (en) Monitoring data acquisition method, and cloud terminal
CN110324677B (en) Bullet screen server connection method, client and readable storage medium
CN110324391B (en) Bullet screen server connection method, client and readable storage medium
CN110324229B (en) Bullet screen server connection method, client and readable storage medium
US10542434B2 (en) Evaluating as to whether or not a wireless terminal is authorized
US11403091B1 (en) Application healthcheck communicator
CN110324642B (en) Bullet screen server connection method, client and readable storage medium
CN110245523B (en) Data verification method, system and device and computer readable storage medium
CN109819278B (en) Optimization method of live video
CN107566809B (en) Video monitoring alarm method, device and system
CN106487776B (en) Method, network entity and system for protecting machine type communication equipment

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