mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
change server timeout longer, recv timeout from 5s to 30s
This commit is contained in:
parent
a9a6a7cdcd
commit
3dbb2132d3
7 changed files with 46 additions and 28 deletions
|
@ -42,11 +42,6 @@ using namespace std;
|
|||
#include <srs_core_http.hpp>
|
||||
#include <srs_core_bandwidth.hpp>
|
||||
|
||||
#define SRS_PULSE_TIMEOUT_MS 100
|
||||
#define SRS_SEND_TIMEOUT_US 5000000L
|
||||
#define SRS_RECV_TIMEOUT_US SRS_SEND_TIMEOUT_US
|
||||
#define SRS_STREAM_BUSY_SLEEP_MS 2000
|
||||
|
||||
SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||
: SrsConnection(srs_server, client_stfd)
|
||||
{
|
||||
|
@ -198,7 +193,7 @@ int SrsClient::service_cycle()
|
|||
srs_warn("stream %s is already publishing. ret=%d",
|
||||
req->get_stream_url().c_str(), ret);
|
||||
// to delay request
|
||||
st_usleep(SRS_STREAM_BUSY_SLEEP_MS * 1000);
|
||||
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -324,12 +319,12 @@ int SrsClient::playing(SrsSource* source)
|
|||
SrsAutoFree(SrsConsumer, consumer, false);
|
||||
srs_verbose("consumer created success.");
|
||||
|
||||
rtmp->set_recv_timeout(SRS_PULSE_TIMEOUT_MS * 1000);
|
||||
rtmp->set_recv_timeout(SRS_PULSE_TIMEOUT_US);
|
||||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_PLAY_USER);
|
||||
|
||||
while (true) {
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_MS);
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_US / 1000);
|
||||
|
||||
// switch to other st-threads.
|
||||
st_usleep(0);
|
||||
|
|
|
@ -37,11 +37,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_config.hpp>
|
||||
#include <srs_core_rtmp.hpp>
|
||||
#include <srs_core_pithy_print.hpp>
|
||||
#include <srs_core_protocol.hpp>
|
||||
|
||||
#ifdef SRS_FFMPEG
|
||||
|
||||
#define SRS_ENCODER_SLEEP_MS 2000
|
||||
|
||||
#define SRS_ENCODER_COPY "copy"
|
||||
#define SRS_ENCODER_VCODEC "libx264"
|
||||
#define SRS_ENCODER_ACODEC "libaacplus"
|
||||
|
@ -483,7 +482,7 @@ void SrsFFMPEG::stop()
|
|||
|
||||
SrsEncoder::SrsEncoder()
|
||||
{
|
||||
pthread = new SrsThread(this, SRS_ENCODER_SLEEP_MS);
|
||||
pthread = new SrsThread(this, SRS_ENCODER_SLEEP_US);
|
||||
pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
|
||||
}
|
||||
|
||||
|
@ -549,7 +548,7 @@ int SrsEncoder::cycle()
|
|||
|
||||
// pithy print
|
||||
encoder();
|
||||
pithy_print->elapse(SRS_ENCODER_SLEEP_MS);
|
||||
pithy_print->elapse(SRS_ENCODER_SLEEP_US / 1000);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_source.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
||||
#define SRS_PULSE_TIMEOUT_MS 100
|
||||
#define SRS_FORWARDER_SLEEP_MS 2000
|
||||
#define SRS_SEND_TIMEOUT_US 3000000L
|
||||
#define SRS_RECV_TIMEOUT_US SRS_SEND_TIMEOUT_US
|
||||
|
||||
SrsForwarder::SrsForwarder(SrsSource* _source)
|
||||
{
|
||||
source = _source;
|
||||
|
@ -51,7 +46,7 @@ SrsForwarder::SrsForwarder(SrsSource* _source)
|
|||
stfd = NULL;
|
||||
stream_id = 0;
|
||||
|
||||
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_MS);
|
||||
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US);
|
||||
queue = new SrsMessageQueue();
|
||||
jitter = new SrsRtmpJitter();
|
||||
}
|
||||
|
@ -286,7 +281,7 @@ int SrsForwarder::forward()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
client->set_recv_timeout(SRS_PULSE_TIMEOUT_MS * 1000);
|
||||
client->set_recv_timeout(SRS_PULSE_TIMEOUT_US);
|
||||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_FORWARDER);
|
||||
|
||||
|
@ -322,7 +317,7 @@ int SrsForwarder::forward()
|
|||
SrsAutoFree(SrsSharedPtrMessage*, msgs, true);
|
||||
|
||||
// pithy print
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_MS);
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_US / 1000);
|
||||
if (pithy_print.can_print()) {
|
||||
srs_trace("-> time=%"PRId64", msgs=%d, obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
||||
pithy_print.get_age(), count, client->get_send_bytes(), client->get_recv_bytes(), client->get_send_kbps(), client->get_recv_kbps());
|
||||
|
|
|
@ -282,8 +282,6 @@ messages.
|
|||
/****************************************************************************
|
||||
*****************************************************************************
|
||||
****************************************************************************/
|
||||
// when got a messae header, increase recv timeout to got an entire message.
|
||||
#define SRS_MIN_RECV_TIMEOUT_US 3000
|
||||
|
||||
SrsProtocol::AckWindowSize::AckWindowSize()
|
||||
{
|
||||
|
|
|
@ -36,6 +36,37 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_log.hpp>
|
||||
#include <srs_core_error.hpp>
|
||||
|
||||
// the following is the timeout for rtmp protocol,
|
||||
// to avoid death connection.
|
||||
|
||||
// when got a messae header, there must be some data,
|
||||
// increase recv timeout to got an entire message.
|
||||
#define SRS_MIN_RECV_TIMEOUT_US 60*1000*1000L
|
||||
|
||||
// the timeout to wait for client control message,
|
||||
// if timeout, we generally ignore and send the data to client,
|
||||
// generally, it's the pulse time for data seding.
|
||||
#define SRS_PULSE_TIMEOUT_US 200*1000L
|
||||
|
||||
// the timeout to wait client data,
|
||||
// if timeout, close the connection.
|
||||
#define SRS_SEND_TIMEOUT_US 30*1000*1000L
|
||||
|
||||
// the timeout to send data to client,
|
||||
// if timeout, close the connection.
|
||||
#define SRS_RECV_TIMEOUT_US 30*1000*1000L
|
||||
|
||||
// when stream is busy, for example, streaming is already
|
||||
// publishing, when a new client to request to publish,
|
||||
// sleep a while and close the connection.
|
||||
#define SRS_STREAM_BUSY_SLEEP_US 3*1000*1000L
|
||||
|
||||
// when error, forwarder sleep for a while and retry.
|
||||
#define SRS_FORWARDER_SLEEP_US 3*1000*1000L
|
||||
|
||||
// when error, encoder sleep for a while and retry.
|
||||
#define SRS_ENCODER_SLEEP_US 3*1000*1000L
|
||||
|
||||
class SrsSocket;
|
||||
class SrsBuffer;
|
||||
class SrsPacket;
|
||||
|
|
|
@ -54,10 +54,10 @@ void ISrsThreadHandler::on_leave_loop()
|
|||
{
|
||||
}
|
||||
|
||||
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_ms)
|
||||
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us)
|
||||
{
|
||||
handler = thread_handler;
|
||||
cycle_interval_milliseconds = interval_ms;
|
||||
cycle_interval_us = interval_us;
|
||||
|
||||
tid = NULL;
|
||||
loop = false;
|
||||
|
@ -143,7 +143,7 @@ failed:
|
|||
break;
|
||||
}
|
||||
|
||||
st_usleep(cycle_interval_milliseconds * 1000);
|
||||
st_usleep(cycle_interval_us);
|
||||
}
|
||||
|
||||
handler->on_leave_loop();
|
||||
|
|
|
@ -85,14 +85,14 @@ private:
|
|||
bool loop;
|
||||
private:
|
||||
ISrsThreadHandler* handler;
|
||||
int64_t cycle_interval_milliseconds;
|
||||
int64_t cycle_interval_us;
|
||||
public:
|
||||
/**
|
||||
* initialize the thread.
|
||||
* @param thread_handler, the cycle handler for the thread.
|
||||
* @param interval_ms, the sleep interval when cycle finished.
|
||||
* @param interval_us, the sleep interval when cycle finished.
|
||||
*/
|
||||
SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_ms);
|
||||
SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us);
|
||||
virtual ~SrsThread();
|
||||
public:
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue