-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLUSTER: Request non-existent HTTP streams, log flooding, thread does not exit, FD leakage. #636
Comments
According to code tracing, the HTTP client thread has been continuously inside the SrsLiveStream::serve_http interface without coming out. This causes the client thread to not reach the logic code that checks whether the HTTP connection still exists, even if the HTTP connection is disconnected. By reading the implementation of other business functions, it seems that when the edge server pulls the stream from the source station, it should start another thread instead of stacking it on the HTTP client thread.
|
The while loop in SrsLiveStream::serve_http is missing a logic to check if the HTTP client connection still exists.
|
HTTP long connection, unless data is written, there is no way to know if the client has disconnected, because no data is read from the client after entering FLV.
|
This is because of the issue with the origin retrieval strategy. If there is no stream, the origin server should return a 404 error, and then the 404 error should be passed from the origin server to the edge server, and the edge server should give a 404 error to the player. However, this issue requires significant changes and cannot be addressed in SRS2 in time.
|
Take another look, it will cause the fd not to close.
|
You should open a coroutine to receive data from the fd. If the client closes the fd, the reading coroutine will return an error.
|
Similar to reading RTMP CONNECTION: srs/trunk/src/app/srs_app_rtmp_conn.cpp Line 717 in ff87318
For RTMP playback clients, only a very small number of requests are sent from the client to the server, while the majority are sent from the server to the client. Therefore, a new coroutine is created for reading, while the main coroutine is mainly responsible for sending. For FLV players, there are no read requests, only write requests. Therefore, a new coroutine can be created to block at the read location, and if the client closes the file descriptor, the read coroutine will return an error. The main coroutine's loop is mainly for sending data, and it checks the read coroutine at each iteration.
|
For some players, after a successful connection, if they request a non-existent HTTP-FLV, the connection will not be actively disconnected and will remain open. In this situation, although there won't be a "close_wait" state, both sides will be stuck here, so it is better for SRS to actively respond with a 404.
|
The SRS configuration is as follows:
Directly access the player multiple times: http://www.ossrs.net/players/srs_player.html?app=live&stream=livestream.flv&server=localhost&port=8080&autostart=true&vhost=localhost&schema=http You can see many
You can see many FDs (10-15) not closed:
|
Open a new ST receiving thread to read the HTTP request. Since HTTP-FLV does not have any subsequent requests, the receiving thread will encounter an error and exit when the client closes the connection. Generally, HTTP requests are handled in this way:
However, in
In the thread
There is a change, in fact, HTTP Streaming (FLV/TS) is replaced by When the player is closed, the receiving thread detects that the SOCKET has been RESET, which means it has been closed by the client, and the thread interrupts the loop.
No FD leakage displayed.
It actually took 52 minutes to solve this problem. In the case of such a simple ST architecture, it can be considered a relatively troublesome problem...
|
Compilation failed under Ubuntu.
|
@chenliang2017 Please file another bug. |
Fixed by f2b4bc7 |
SRS version:
[root@localhost trunk]# ./objs/srs -v
2.0.214
Configuration:
Operation:
Without any streaming, initiate a pull request to the server through the browser.
Phenomenon:
The following logs are repeatedly displayed, even if the HTTP connection of the browser is disconnected, the following prints continue to be displayed.
TRANS_BY_GPT3
The text was updated successfully, but these errors were encountered: