Skip to content

Commit

Permalink
Fixed obs not responding to ping command causing push stream disconne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
illuspas authored and datagutt committed Oct 31, 2019
1 parent 49649dc commit f2a52d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion node_rtmp_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class NodeRtmpSession {
this.pingTime = config.rtmp.ping ? config.rtmp.ping * 1000 : RTMP_PING_TIME;
this.pingTimeout = config.rtmp.ping_timeout ? config.rtmp.ping_timeout * 1000 : RTMP_PING_TIMEOUT;
this.pingInterval = null;
this.pingReset = false;
this.pingResponseTime = 0;

this.isLocal = this.ip === "127.0.0.1" || this.ip === "::1" || this.ip == "::ffff:127.0.0.1";
Expand Down Expand Up @@ -233,6 +234,7 @@ class NodeRtmpSession {
}

onSocketData(data) {
this.pingReset = true;
let bytes = data.length;
let p = 0;
let n = 0;
Expand Down Expand Up @@ -950,7 +952,7 @@ class NodeRtmpSession {

sendPingRequest() {
let currentTimestamp = Date.now() - this.startTimestamp;
if(currentTimestamp - this.pingResponseTime > this.pingTimeout) {
if(currentTimestamp - this.pingResponseTime > this.pingTimeout && !this.pingReset) {
Logger.log(`[rtmp ping timout] id=${this.id}`);
this.stop();
return;
Expand All @@ -964,6 +966,7 @@ class NodeRtmpSession {
packet.header.length = packet.payload.length;
let chunks = this.rtmpChunksCreate(packet);
this.socket.write(chunks);
this.pingReset = false;
}

respondConnect(tid) {
Expand Down

0 comments on commit f2a52d9

Please sign in to comment.