From 9f225aeb7c352312b7f39097afdeefbc3b39d371 Mon Sep 17 00:00:00 2001 From: Paul Gregoire <mondain@gmail.com> Date: Thu, 8 Feb 2024 08:02:11 -0800 Subject: [PATCH] Externalize max_poll_time for RTMPConnection --- .../org/red5/server/net/rtmp/RTMPConnection.java | 15 ++++++++++++++- server/src/main/server/conf/red5-core.xml | 2 ++ server/src/main/server/conf/red5.properties | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java b/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java index e63c8181..6a5c1715 100755 --- a/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java +++ b/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java @@ -295,6 +295,11 @@ public abstract class RTMPConnection extends BaseConnection implements IStreamCa */ protected long maxHandlingTimeout = 500L; + /** + * Maximum time in milliseconds to wait for a message. + */ + private long maxPollTimeout = 10000L; + /** * Bandwidth limit type / enforcement. (0=hard,1=soft,2=dynamic) */ @@ -1513,7 +1518,7 @@ public abstract class RTMPConnection extends BaseConnection implements IStreamCa do { try { // DTS appears to be off only by < 10ms - Packet p = receivedPacketQueue.poll(10000L, TimeUnit.MILLISECONDS); // wait for a packet up to 10 seconds + Packet p = receivedPacketQueue.poll(maxPollTimeout, TimeUnit.MILLISECONDS); // wait for a packet up to 10 seconds if (p != null) { if (isTrace) { log.trace("Handle received packet: {}", p); @@ -1860,6 +1865,14 @@ public abstract class RTMPConnection extends BaseConnection implements IStreamCa this.maxHandlingTimeout = maxHandlingTimeout; } + public long getMaxPollTimeout() { + return maxPollTimeout; + } + + public void setMaxPollTimeout(long maxPollTimeout) { + this.maxPollTimeout = maxPollTimeout; + } + public int getChannelsInitalCapacity() { return channelsInitalCapacity; } diff --git a/server/src/main/server/conf/red5-core.xml b/server/src/main/server/conf/red5-core.xml index a56be7ea..0e178eed 100644 --- a/server/src/main/server/conf/red5-core.xml +++ b/server/src/main/server/conf/red5-core.xml @@ -112,6 +112,8 @@ <property name="maxInactivity" value="${rtmp.max_inactivity}" /> <!-- Max. time in milliseconds to wait for a valid handshake. --> <property name="maxHandshakeTimeout" value="${rtmp.max_handshake_time}" /> + <!-- Max. time in milliseconds to wait for a message while polling --> + <property name="maxPollTimeout" value="${rtmp.max_poll_time}" /> <!-- Default server bandwidth per connection --> <property name="defaultServerBandwidth" value="${rtmp.default_server_bandwidth}" /> <!-- Default client bandwidth per connection --> diff --git a/server/src/main/server/conf/red5.properties b/server/src/main/server/conf/red5.properties index 931abc5a..810dd230 100644 --- a/server/src/main/server/conf/red5.properties +++ b/server/src/main/server/conf/red5.properties @@ -23,6 +23,8 @@ rtmp.max_read_buffer_size=65536 rtmp.ping_interval=1000 rtmp.max_inactivity=60000 rtmp.max_handshake_time=5000 +# maximum time to wait for a message while polling in milliseconds +rtmp.max_poll_time=10000 rtmp.tcp_nodelay=true rtmp.tcp_keepalive=false rtmp.default_server_bandwidth=10000000 -- GitLab