CN110324229B - 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
CN110324229B
CN110324229B CN201810294982.8A CN201810294982A CN110324229B CN 110324229 B CN110324229 B CN 110324229B CN 201810294982 A CN201810294982 A CN 201810294982A CN 110324229 B CN110324229 B CN 110324229B
Authority
CN
China
Prior art keywords
bullet screen
server
connection
client
live broadcast
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
CN201810294982.8A
Other languages
Chinese (zh)
Other versions
CN110324229A (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 CN201810294982.8A priority Critical patent/CN110324229B/en
Publication of CN110324229A publication Critical patent/CN110324229A/en
Application granted granted Critical
Publication of CN110324229B publication Critical patent/CN110324229B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • H04L51/046Interoperability with other network applications or services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4555Directories for electronic mail or instant messaging
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1023Server selection for load balancing based on a hash applied to IP addresses or costs

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (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 live application program is detected to start a barrage function and enters a first direct broadcasting 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 application program entering the first live broadcast room within a first preset historical 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.

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 a live broadcast application program is in live broadcast, a viewer sends a bullet screen to well play a role in interacting with a main broadcast. Due to the fact that the data volume of the bullet screen is very large and the real-time performance of the bullet screen is high, the server system of the live broadcast application program independently opens the bullet screen server, and full time is responsible for receiving and sending bullet screen information. In the prior art, the bullet screen server is connected firstly in the connection process, and then is connected to the corresponding bullet screen server through the gateway server, so that the connection process is complicated, and the connection speed is low.
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 speed 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 for installing a live application program, including:
connecting to a gateway server under the condition that the live application program is detected to start a barrage function and enters a first direct broadcasting 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 application program entering the first live broadcast room within a first preset historical 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.
Optionally, before the connecting to the gateway server, the method further includes:
live broadcast application gets into at every turn under the first live broadcast room connection barrage server condition, if connect successfully, the record with first live broadcast room corresponds the connection success record of barrage server, if connect failure, the record with first live broadcast room corresponds the connection failure record of barrage server to form with the barrage server historical connection record that first live broadcast room corresponds.
Optionally, the connecting, based on the historical connection record of the bullet screen server, the bullet screen servers in the first candidate bullet screen server list according to a preset policy includes:
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 historical 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 historical 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.
Optionally, the first candidate barrage server list includes a domain name address of at least one barrage server, and the connecting, according to the power from high to low, the barrage servers in the first candidate barrage server list until the connection is successful includes:
sequentially selecting one bullet screen server from the first candidate bullet screen server list according to the sequence of the power from high to low, and acquiring the domain name address of the selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the selected bullet screen server;
and connecting the selected bullet screen server based on the IP address and the port number of the selected bullet screen server until the connection is successful or all the bullet screen servers in the first candidate bullet screen server list are failed to be connected.
Optionally, if all of the bullet screen servers in the first candidate bullet screen server list fail to be connected, the method further includes:
receiving a second candidate barrage server list sent by the gateway server, wherein the second candidate barrage server list comprises an IP address and a port of each barrage server in at least one barrage server;
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 second candidate bullet screen server list within a second preset historical time range;
and connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the power from high to low until the connection is successful.
Optionally, if all of the bullet screen servers in the second candidate bullet screen server list fail to be connected, the method further includes:
and connecting the bullet screen server based on the HTTP.
In a second aspect, an embodiment of the present invention provides a client, including:
the first connection unit is used for connecting to a gateway server when detecting that the live application program starts a barrage function and enters a first live broadcasting room;
the first acquisition unit is used for acquiring a first candidate barrage server list sent by the gateway server;
the second acquisition unit is used for acquiring a historical connection record of the bullet screen server corresponding to the first live broadcast room, wherein the historical connection record of the bullet screen server comprises a record of the live broadcast application program which is connected with the bullet screen server during entering the first live broadcast room within a first preset historical time range;
and the second connecting unit is used for 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.
Optionally, the client further includes:
the recording unit is used for being connected to the gateway server before the live broadcast application program enters into at every time under the condition that the barrage server is connected between the first live broadcast rooms, if the connection is successful, the recording is in correspondence with the first live broadcast rooms, the connection success recording of the barrage server is recorded, if the connection is failed, the recording is in correspondence with the first live broadcast rooms, and the barrage server history connection record corresponding to the first live broadcast rooms is formed.
Optionally, the second connection unit is configured to:
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 historical 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 historical 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.
Optionally, the second connection unit is configured to:
the first candidate barrage server list comprises domain name addresses of at least one barrage server, and one barrage server is sequentially selected from the first candidate barrage server list according to the sequence of the power from high to low to obtain the domain name address of the selected barrage server;
analyzing the domain name address to obtain the IP address and the port number of the selected bullet screen server;
and connecting the selected bullet screen server based on the IP address and the port number of the selected bullet screen server until the connection is successful or all the bullet screen servers in the first candidate bullet screen server list are failed to be connected.
Optionally, the client further includes:
a third connection unit, configured to receive a second candidate bullet screen server list sent by the gateway server 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 of each bullet screen server in at least one bullet screen server;
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 second candidate bullet screen server list within a second preset historical time range;
and connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the 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 based on the HTTP if the bullet screen servers in the second candidate bullet screen server list are failed to connect.
In a third 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 fourth 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 aspect embodiment.
One or more technical solutions in the embodiments of the present application have at least one or more of the following technical effects:
according to the technical scheme of the embodiment of the invention, under the condition that the live broadcast application program starts the barrage function and enters the first live broadcast room, the live broadcast application program is connected to the gateway server; and acquiring a first candidate barrage server list sent by the gateway server. Furthermore, a historical connection record of the bullet screen server corresponding to the first direct broadcasting room is required to be obtained, wherein the historical connection record of the bullet screen server comprises a record of a live broadcast application program entering the bullet screen server during the first direct broadcasting room within a first preset historical time range; and then 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. The connection sequence corresponding to the bullet screen servers in the first candidate bullet screen server list can be determined through the historical connection records, the bullet screen servers which are easy to connect can be preferentially connected, and then the speed of the client side in connection 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 schematic diagram of a client according to a second 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 speed of connecting the client with a bullet screen server. The method comprises the following steps: connecting to a gateway server under the condition that the live application program is detected to start a barrage function and enters a first direct broadcasting 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 application program entering the first live broadcast room within a first preset historical 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.
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 live application program is detected to start a barrage function and enters a first direct broadcasting room;
s102: acquiring a first candidate barrage server list sent by the gateway server;
s103: 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 application program entering the first live broadcast room within a first preset historical time range;
s104: 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, the bullet screen server connection method in this embodiment is mainly applied to a client installed with a live application program. 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. The client needs to be connected with the gateway server, and then is connected with the corresponding barrage server through the gateway server.
Specifically, in this embodiment, the following conditions may trigger the client to connect to the bullet screen server: firstly, after the live broadcast application program is started, if the live broadcast application program starts the barrage function, the user clicks to enter a first live broadcast room at the moment, and the client is triggered to be connected with the barrage server. And secondly, after the live broadcast application program is started, the user clicks to enter the first live broadcast room, the user starts the barrage function during watching the first live broadcast room, and the client is triggered to be connected with the barrage server.
Further, when triggered to connect to the bullet screen server, the client first connects to the gateway server in 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.
Further, in this embodiment, before the client is connected to the gateway server, the live broadcast application program enters each time under the condition that the barrage server is connected to the first live broadcast room, if the connection is successful, the connection success record of the barrage server corresponding to the first live broadcast room is recorded, and if the connection is failed, the connection failure record of the barrage server corresponding to the first live broadcast room is recorded, so as to form a barrage server history connection record corresponding to the first live broadcast room.
Specifically, the client records the record of each time the live application program enters the first live room connection barrage server, including the connection success record and the connection failure record. Under the condition that the live broadcast application program opens the bullet screen function, the live broadcast application program can be connected with the bullet screen server every time the live broadcast application program enters the first live broadcast room, and the bullet screen server can be selected from the candidate list to be connected according to the connection mode of the bullet screen server until the connection is successful. 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.
After receiving the first candidate barrage server list, the client executes step S103. The record of the bullet screen server connected during the first direct broadcasting time within the first preset time range can be screened out from the bullet screen server historical connection records 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 a 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, since there is a case that the domain name address is hijacked, which results in that the client cannot resolve the IP address of the bullet screen server, or the acquired IP address is not connected to the bullet screen server, there is also a case that the client fails to connect all the bullet screen servers in the first candidate bullet screen server list. And if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected. 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 further use an IP list corresponding to the latest connected bullet screen server as a second candidate bullet screen server list.
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, 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 fail to connect, the bullet screen server connection method in this embodiment further provides a bullet screen server connection policy based on HTTP, so that if all the bullet screen servers in the second candidate bullet screen server list fail 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 live application starts the bullet screen function, since the live 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 the live application program is started, the barrage function of the live application program is started, and when the barrage function is triggered to play video, the client detects the state of network connection. Such as: the live 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. And secondly, when the barrage function is started during video playing after the live 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 operation of the live application program in the client, if the live application program starts the barrage function, the client may detect the current network connection state at preset time intervals (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 that the client is triggered to detect the current network connection state, if the situation is the third situation, during the running period of the live broadcast application program in the client, if the live broadcast application program starts the barrage function, the client may detect the current network connection state at preset time intervals (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 live broadcast application, 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 live application program; if the running state of the live broadcast 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 live broadcast application program is switched from the background running state to the foreground running state, reconnecting the bullet screen server.
Specifically, in this embodiment, when the client connects to the barrage server and completes the sending and receiving of the barrage information, the running state of the live broadcast application program is monitored, for example: check the running state of live broadcast application according to preset time interval (if 5 minutes, 10 minutes etc.), if live broadcast application is in the proscenium running state, the client side continues to carry out the transmission of barrage information with the barrage server who is connected, if the running state of live broadcast application is switched to backstage running state by proscenium running state, to live broadcast application, withdraw from the backstage and mean that spectator has not seen the live broadcast, also can not see the barrage simultaneously, so, the client side can stop connecting the barrage server, can not go continuous connection barrage server. And when detecting that the live broadcast application program is switched to the foreground operation again, the live broadcast application program can be reconnected with the bullet screen server.
Further, in this embodiment, a waiting duration (e.g., 5 minutes, 10 minutes, etc.) may be set, when the live broadcast application is switched to the background operation, if the duration in the background operation reaches the waiting duration, the client interrupts the connection with the bullet screen server, and during the duration in the background operation of the live broadcast application does not reach the waiting duration, the client maintains the connection with the bullet screen server, so that when the live broadcast application is switched back to the foreground operation state in a short time, the client can receive and send the bullet screen information in time. When the live application program is in a background running state for a long time, the client can automatically interrupt the connection with the barrage 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 barrage server during the background running of the live application program are solved. Live application at background running state switches over again to the foreground operation, if interrupted the connection between client and barrage server at the background operation, this moment, can the bullet curtain server of the last successful connection of lug connection client, if the connection fails, can carry out the connection of barrage server according to the mode of connecting barrage server in aforementioned embodiment again, here, this application is not repeated.
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 live application 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 is connected with the gateway server, the reported second information Key3 to be verified and the second identity information are carried. 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, the live broadcast room that the user probably will get into can also be predicated when the user gets into the live broadcast application, and then, connect the corresponding barrage server in advance before getting into this live broadcast room, like this, just can in time carry out the receiving and dispatching of barrage information when getting into the live broadcast room. Specifically, the method can be realized by the following steps:
under the condition that the client is detected to start the live application program and the live application program starts a barrage function, acquiring at least one live room concerned by a user logging in the live application program;
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 application program 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 application program through the account password, the user first enters a main function interface of the live application program, at this time, the client acquires at least one live broadcast room that the user is interested in, and since the user is interested in the live broadcast room, it is indicated 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 application program 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.
In this embodiment, a method for maintaining a bullet screen server in a bullet screen server system is further provided, 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 the ID of the live broadcast room where the connection is successful. If the client fails to connect to the barrage server, the record of the failed connection is recorded, including the ID of the client, the identifier of the failed connection (which may be indicated as "0"), the connection time, the ID of the barrage server with the failed connection, the IP address and the port number, and the ID of the live broadcast room where the client is located.
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. 2, a second embodiment of the present invention provides a client, including:
the first connection unit 201 is configured to connect to a gateway server when it is detected that the live application starts a barrage function and the live application enters a first live room;
a first obtaining unit 202, configured to obtain a first candidate barrage server list sent by the gateway server;
a second obtaining unit 203, configured to obtain a historical connection record of a bullet screen server corresponding to the first live broadcast room, where the historical connection record of the bullet screen server includes a record of connection of the bullet screen server during a period when the live broadcast application program enters the first live broadcast room within a first preset historical time range;
and the second connecting unit 204 is configured to connect, based on the historical connection record of the bullet screen servers, the bullet screen servers in the first candidate bullet screen server list according to a preset policy.
Further, the client further comprises:
the recording unit is used for being connected to the gateway server before the live broadcast application program enters into at every time under the condition that the barrage server is connected between the first live broadcast rooms, if the connection is successful, the recording is in correspondence with the first live broadcast rooms, the connection success recording of the barrage server is recorded, if the connection is failed, the recording is in correspondence with the first live broadcast rooms, and the barrage server history connection record corresponding to the first live broadcast rooms is formed.
Further, the second connection unit is configured to:
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 historical 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 historical 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.
Further, the second connection unit is configured to:
the first candidate barrage server list comprises domain name addresses of at least one barrage server, and one barrage server is sequentially selected from the first candidate barrage server list according to the sequence of the power from high to low to obtain the domain name address of the selected barrage server;
analyzing the domain name address to obtain the IP address and the port number of the selected bullet screen server;
and connecting the selected bullet screen server based on the IP address and the port number of the selected bullet screen server until the connection is successful or all the bullet screen servers in the first candidate bullet screen server list are failed to be connected.
Further, the client further comprises:
a third connection unit, configured to receive a second candidate bullet screen server list sent by the gateway server 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 of each bullet screen server in at least one bullet screen server;
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 second candidate bullet screen server list within a second preset historical time range;
and connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the 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 based on the HTTP if the bullet screen servers in the second candidate bullet screen server list are failed to connect.
A third embodiment of the present invention provides a client, including: the system comprises a processor, a memory and a computer program which is stored in the memory and can run 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 second 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.
The server may include, but is not limited to, a processor, a memory. More or fewer components may be included, or certain components may be combined, or different components may be combined, e.g., the server may also include input-output devices, network access devices, buses, etc.
The Processor 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 may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and 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 fourth 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 second embodiment of the present invention may be stored in one computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the invention realizes all or part of the flow in the bullet screen server connection method in the first embodiment, and may also be implemented by instructing relevant hardware through a computer program, where the computer program may be stored in a computer readable storage medium, and when being executed by a processor, the computer program may realize the steps of the above method embodiments. 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.
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 (9)

1. A bullet screen server connection method is applied to a client side for installing a live application program, and is characterized by comprising the following steps:
when detecting that the live application program starts a barrage function and enters a first live broadcasting room, connecting the live application program to a gateway server, and when a client is connected with the gateway server, the client obtains an IP list of the gateway server from a PHP server, and randomly selects one IP and a port for connection each time until the gateway server is successfully connected;
acquiring a first candidate barrage server list sent by the gateway server;
acquiring a historical connection record of a bullet screen server corresponding to the first live broadcast room, wherein the historical connection record of the bullet screen server comprises a connection success record and a connection failure record of the live broadcast application program connected with the bullet screen server during entering the first live broadcast room within a first preset historical time range;
based on the historical connection records of the bullet screen servers, connecting the bullet screen servers in the first candidate bullet screen server list in a domain name resolution mode according to a preset strategy;
if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, receiving a second candidate bullet screen server list sent by the gateway server, wherein the second candidate bullet screen server list comprises the IP address and the port of each bullet screen server in at least one bullet screen server; 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 second candidate bullet screen server list within a second preset historical time range; connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the power from high to low until the connection is successful;
the bullet screen server connection method further comprises the following steps:
under the condition that the client is detected to start the live application program and the live application program starts a barrage function, acquiring at least one live room concerned by a user logging in the live application program;
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 application program is successfully connected with the bullet screen servers before entering the first live broadcast room.
2. The method of claim 1, wherein prior to the connecting to a gateway server, the method further comprises:
live broadcast application gets into at every turn under the first live broadcast room connection barrage server condition, if connect successfully, the record with first live broadcast room corresponds the connection success record of barrage server, if connect failure, the record with first live broadcast room corresponds the connection failure record of barrage server to form with the barrage server historical connection record that first live broadcast room corresponds.
3. The method of claim 2, wherein the connecting the bullet screen servers in the first list of candidate bullet screen servers according to a preset policy based on the historical connection records of the bullet screen servers comprises:
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 historical 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 historical 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.
4. The method of claim 3, wherein the first list of candidate barrage servers includes a domain name address of at least one barrage server, and wherein the connecting the barrage servers in the first list of candidate barrage servers in descending order of power until the connection is successful comprises:
sequentially selecting one bullet screen server from the first candidate bullet screen server list according to the sequence of the power from high to low, and acquiring the domain name address of the selected bullet screen server;
analyzing the domain name address to obtain the IP address and the port number of the selected bullet screen server;
and connecting the selected bullet screen server based on the IP address and the port number of the selected bullet screen server until the connection is successful or all the bullet screen servers in the first candidate bullet screen server list are failed to be connected.
5. The method of claim 4, wherein if all of the bullet screen servers in the second list of candidate bullet screen servers fail to connect, the method further comprises:
and connecting the bullet screen server based on the HTTP.
6. A client, comprising:
the system comprises a first connecting unit, a gateway server and a client, wherein the first connecting unit is used for connecting the gateway server when detecting that a live application program starts a barrage function and enters a first live broadcasting room, and when the client is connected with the gateway server, the client obtains an IP list of the gateway server from a PHP server and randomly selects one IP and a port for connection each time until the gateway server is successfully connected;
the first acquisition unit is used for acquiring a first candidate barrage server list sent by the gateway server;
the second obtaining unit is used for obtaining a historical connection record of the bullet screen server corresponding to the first live broadcast room, wherein the historical connection record of the bullet screen server comprises a connection success record and a connection failure record of the bullet screen server during the live broadcast application program enters the first live broadcast room within a first preset historical time range;
the second connection unit is used for connecting the bullet screen servers in the first candidate bullet screen server list in a domain name resolution mode according to a preset strategy based on the historical connection records of the bullet screen servers; if all the bullet screen servers in the first candidate bullet screen server list are failed to be connected, receiving a second candidate bullet screen server list sent by the gateway server, wherein the second candidate bullet screen server list comprises the IP address and the port of each bullet screen server in at least one bullet screen server; 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 second candidate bullet screen server list within a second preset historical time range; connecting the bullet screen servers in the second candidate bullet screen server list according to the sequence of the power from high to low until the connection is successful;
the second connection unit is further used for acquiring at least one live broadcast room concerned by a user logging in the live broadcast application program when the client is detected to start the live broadcast application program and the live broadcast application program starts a barrage function;
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 application program is successfully connected with the bullet screen servers before entering the first live broadcast room.
7. The client of claim 6, wherein the client further comprises:
the recording unit is used for being connected to the gateway server before the live broadcast application program enters into at every time under the condition that the barrage server is connected between the first live broadcast rooms, if the connection is successful, the recording is in correspondence with the first live broadcast rooms, the connection success recording of the barrage server is recorded, if the connection is failed, the recording is in correspondence with the first live broadcast rooms, and the barrage server history connection record corresponding to the first live broadcast rooms is formed.
8. A client, characterized in that the client comprises a processor for implementing the steps of the bullet screen server connection method according to any one of claims 1 to 5 when executing a computer program stored in a memory.
9. A readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, performs the steps of the bullet screen server connection method according to any one of claims 1 to 5.
CN201810294982.8A 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium Active CN110324229B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810294982.8A CN110324229B (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
CN201810294982.8A CN110324229B (en) 2018-03-30 2018-03-30 Bullet screen server connection method, client and readable storage medium

Publications (2)

Publication Number Publication Date
CN110324229A CN110324229A (en) 2019-10-11
CN110324229B true CN110324229B (en) 2022-04-12

Family

ID=68112374

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN110324229B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113014945B (en) * 2021-03-04 2022-07-22 网易(杭州)网络有限公司 Data processing method and device, storage medium and computer equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105871977A (en) * 2015-11-27 2016-08-17 乐视体育文化产业发展(北京)有限公司 Long connection establishment method and system, and devices
CN105898375A (en) * 2016-07-01 2016-08-24 上海幻电信息科技有限公司 Barrage pushing system and method
CN106028469A (en) * 2016-07-26 2016-10-12 广东欧珀移动通信有限公司 Communication connection establishment method and device, and mobile terminal
CN106302835A (en) * 2015-05-12 2017-01-04 腾讯科技(深圳)有限公司 A kind of service connection method, Analysis server, client and system
CN107172444A (en) * 2017-03-30 2017-09-15 武汉斗鱼网络科技有限公司 A kind of network direct broadcasting reconnection method and system
CN107547484A (en) * 2016-06-29 2018-01-05 上海连尚网络科技有限公司 Message obtains, method, equipment and the system of push

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5738908B2 (en) * 2013-02-18 2015-06-24 株式会社東芝 Information distribution apparatus, information distribution method, and information distribution program
CN105915931A (en) * 2016-06-07 2016-08-31 武汉斗鱼网络科技有限公司 Method of relevantly preserving live video and barrage information and apparatus thereof
CN105939485B (en) * 2016-06-27 2018-11-06 武汉斗鱼网络科技有限公司 System and method based on user's barrage behavior monitoring barrage service availability
CN107396199B (en) * 2017-08-02 2018-08-03 武汉斗鱼网络科技有限公司 Barrage method for exhibiting data and device, computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106302835A (en) * 2015-05-12 2017-01-04 腾讯科技(深圳)有限公司 A kind of service connection method, Analysis server, client and system
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
CN105898375A (en) * 2016-07-01 2016-08-24 上海幻电信息科技有限公司 Barrage pushing system and method
CN106028469A (en) * 2016-07-26 2016-10-12 广东欧珀移动通信有限公司 Communication connection establishment method and device, and mobile terminal
CN107172444A (en) * 2017-03-30 2017-09-15 武汉斗鱼网络科技有限公司 A kind of network direct broadcasting reconnection method and system

Also Published As

Publication number Publication date
CN110324229A (en) 2019-10-11

Similar Documents

Publication Publication Date Title
CN108366277B (en) Bullet screen server connection method, client and readable storage medium
US10200729B2 (en) Systems and methods for autonomous broadcasting
CN109089168B (en) Video sharing method, device and system and storage medium
CN110324296B (en) Bullet screen server connection method and device and client
US20120155358A1 (en) Adaptive mobile multicasting for wireless networks
KR20170012873A (en) Method, apparatus and system for voice verification
CN107426253B (en) Data verification method and client
US9787735B2 (en) Methods, devices, and systems for live video streaming from a remote location based on a received request utilizing keep alive messages
US20160173686A1 (en) Method, system and electronic device for remotely recording and authenticating associated recorded files
CN108023727B (en) Authorization method and system thereof
WO2019061598A1 (en) Data verification method and client
AU2015245702A1 (en) Method of delivering and protecting media content
WO2019061628A1 (en) Data verification method, and server
EP3391608B1 (en) Handling of content delivery in a client node
WO2019061627A1 (en) Data verification method, and server
CN110324229B (en) Bullet screen server connection method, client and readable storage medium
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
US20180219926A1 (en) Methods, devices, and systems for live video streaming from a remote location based on a set of local criteria
CN110324642B (en) Bullet screen server connection method, client and readable storage medium
CN108055356A (en) A kind of information processing method, server, client and readable storage medium storing program for executing
CN110245523B (en) Data verification method, system and device and computer readable storage medium
KR101517865B1 (en) Digital rights management with irregular network access
US20150249868A1 (en) Internet protocol television tiered service delivery over wi-fi networks

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