Skip to content
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

srs rejects request while downstream server disconnects and then reconnects in a short time. #2284

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,7 @@ srs_error_t SrsConfig::check_normal_config()
&& e != "acodec" && e != "abitrate" && e != "asample_rate" && e != "achannels"
&& e != "aparams" && e != "output" && e != "perfile"
&& e != "iformat" && e != "oformat") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.transcode.engine.%s of %s", m.c_str(), vhost->arg0().c_str());
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.transcode.engine.%s of %s", e.c_str(), vhost->arg0().c_str());
}
}
}
Expand Down
21 changes: 14 additions & 7 deletions trunk/src/app/srs_app_forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,32 @@ srs_error_t SrsForwarder::on_video(SrsSharedPtrMessage* shared_video)
srs_error_t SrsForwarder::cycle()
{
srs_error_t err = srs_success;

while (true) {
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "forwarder");
}

if ((err = do_cycle()) != srs_success) {
srs_warn("Forwarder: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

//
// 将trd->pull()检测移到do_cycle之后,以便当正常的下游服务器断开连接的时候,不用再
// srs_usleep(SRS_FORWARDER_CIMS),避免下游服务器马上重连的时候失败的情况发生。
//
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
Copy link
Member

@winlinvip winlinvip Oct 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much 👍

It would be more appropriate to add error detection before and after the Forward cycle.

I have already merged this place: link

TRANS_BY_GPT3

return srs_error_wrap(err, "forwarder");
}

srs_usleep(SRS_FORWARDER_CIMS);
}

return err;
}



srs_error_t SrsForwarder::do_cycle()
{
srs_error_t err = srs_success;
Expand Down