-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
RTSP: RECEIVE operation still returns CURLE_OK when the connection is broken #15624
Comments
I tried to add a check in rtsp_done() in curl/lib/rtsp.c. static CURLcode rtsp_done(struct Curl_easy *data,
CURLcode status, bool premature)
{
struct RTSP *rtsp = data->req.p.rtsp;
CURLcode httpStatus;
/* Bypass HTTP empty-reply checks on receive */
if(data->set.rtspreq == RTSPREQ_RECEIVE)
premature = TRUE;
httpStatus = Curl_http_done(data, status, premature);
if(rtsp && !status && !httpStatus) {
/* Check the sequence numbers */
long CSeq_sent = rtsp->CSeq_sent;
long CSeq_recv = rtsp->CSeq_recv;
if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
failf(data,
"The CSeq of this request %ld did not match the response %ld",
CSeq_sent, CSeq_recv);
return CURLE_RTSP_CSEQ_ERROR;
}
if(data->set.rtspreq == RTSPREQ_RECEIVE &&
(data->conn->proto.rtspc.rtp_channel == -1)) {
infof(data, "Got an RTP Receive with a CSeq of %ld", CSeq_recv);
}
/* Here is the added code */
if(data->set.rtspreq == RTSPREQ_RECEIVE &&
data->req.eos_written) {
failf(data, "The req.eos_written bit is set in the Receive request");
return CURLE_RECV_ERROR;
}
}
return httpStatus;
} This change works. Is it OK to check via |
Thanks for your report. If I understand the issue correctly, the transfer ends prematurely. I wonder if |
Thanks @dengjfzh. Lacking a real RTSP server, I am not sure what I am looking at. In Could you run this with a |
|
Ok, learning about this protocol a bit. As I understand now, Reading the RTSP RFC, this protocol looks like HTTP but is not. Especially when it comes to RTSP sessions. Opening one introduces a state in the connection. If the server closes the connection before the client issues a If so, I understand your proposed fix. It implies that a client never does |
That's right. This is my test data: log file: Network capture file: |
I did this
I use libcurl to download a RTSP stream from a server, then restart the server, libcurl cannot report an error (the connection was broken).
This is my test code:
Note that in this test code, when the connection is broken, the curl_easy_perform() call will immediately return CURLE_OK, resulting in 100% CPU usage.
Attached is the log.
log.txt
I expected the following
When the connection is broken, curl_easy_perform() should return an error code so that the application can handle it accordingly.
curl/libcurl version
curl 8.11.0
operating system
Ubuntu 24.04
The text was updated successfully, but these errors were encountered: