illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.89k stars 1.51k forks source link

Bitrate value does not change to 0 when no data is received #585

Open EisaK opened 1 year ago

EisaK commented 1 year ago

Hello,

I'm testing disconnection scenarios to NMS.

Ideally, the bitrate value seen in http://localhost:8000/api/streams/publish/live from src/api/controllers/streams.js should change to 0 when no data is received by the server. However, the bitrate value remains the last known bitrate value before disconnection.

I'm a programming novice, but I looked through node_rtmp_session.js It appears that this.bitrate is updated in the rtmpChunkRead function, which is called during the onSocketData function. My guess is that since no data is arriving at the server, onSocketData isn't called, and this.bitrate isn't updating. I'm not sure what exact fix is needed though to ensure rtmpChunkRead keeps happening after losing connection.