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.96k stars 1.52k forks source link

HTTP flv.js client drops connection #4

Open rebelvg opened 7 years ago

rebelvg commented 7 years ago

Hey, first of all, great repo, love it.

Issue. HTTP flv.js player drops connection after about 30 minutes. Here's logs from the browser and nodejs console. At the same time I launched ffplay and it didn't drop the connection. So the issue possibly lies in the flv.js player. Edit: looks like it's really a flv.js player issue. Please close this ticket if there's no need for it. Another edit: Not sure if it's completely player issue. https://github.com/Bilibili/flv.js/blob/master/docs/cors.md This link here says that OPTIONS http request will be made at some point and server should respond, but in this case, server drops the connection because it can only answer on GET correctly. According to the log, MSE SourceBuffer gets full and it attempts to play video after that, sends OPTIONS request and server responds with res.end() closing the connection. https://github.com/illuspas/Node-Media-Server/blob/5bbb9a76f27a967fc7a32498f6619eaf926ba9f6/node_http_session.js#L62

[MSEController] > MediaSource onSourceOpen logger.js:123:8 [FLVDemuxer] > Parsed onMetaData logger.js:123:8 [FLVDemuxer] > Parsed AudioSpecificConfig logger.js:123:8 [FLVDemuxer] > Parsed AVCDecoderConfigurationRecord logger.js:123:8 [MSEController] > Received Initialization Segment, mimeType: audio/mp4;codecs=mp4a.40.2 logger.js:123:8 [MSEController] > Received Initialization Segment, mimeType: video/mp4;codecs=avc1.64001f logger.js:123:8 [FlvPlayer] > MSE SourceBuffer is full, suspend transmuxing task logger.js:123:8 [FlvPlayer] > Continue loading from paused position logger.js:123:8 OPTIONS XHR http://127.0.0.1:8000/live/main.flv [HTTP/1.1 405 Method Not Allowed 2ms] Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8000/live/main.flv. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). (unknown) [IOController] > Loader error, code = -1, msg = ProgressEvent error logger.js:38:12 [TransmuxingController] > IOException: type = Exception, code = -1, msg = ProgressEvent error logger.js:38:12 Error: Uncaught, unspecified "error" event. (NetworkError) events.js:62

Parse AudioTagHeader sound_format=10 sound_type=1 sound_size=1 sound_rate=3 Parse VideoTagHeader frame_type=1 codec_id=7 [http-flv play] play stream live/main [http-flv play] join stream live/main http-flv parse message [start] [http-flv play] play stream live/main [http-flv play] join stream live/main http-flv parse message [start] http-flv parse message [stop] Unsupported method=OPTIONS

illuspas commented 7 years ago

It seems that there is no response to the OPTIONS method that caused this error.

rebelvg commented 7 years ago

Yeah, looks like it.

illuspas commented 7 years ago

But an hour and a half passed I have not caught this error, can not test whether the problem is fixed. What is your test environment,Operating system, browser version.

rebelvg commented 7 years ago

Windows 7, node 8.2.1, Firefox 56 beta, FLV.js player 1.3.2.

rebelvg commented 7 years ago

My guess is, since player uses different tricks to get this to work on different browsers, this may only happen with desktop firefox implementation of MSE. I'll try to reproduce this on different browsers.

xqq commented 7 years ago

If you received "MSE SourceBuffer is full, suspend transmuxing task" under a live stream, It means the playback progress is slowly than the network stream polling progress. Then the SourceBuffer got full, and cannot append any segments anymore.

So have you found any audio-video unsync issue, or incorrect playback speed issue?

rebelvg commented 7 years ago

Yes, that was a livestream. Tested this yesterday on localhost and live server, player worked completely fine, playback speed was correct and then it stopped. After a few times of the same behavior I decided to test it on localhost and this is where the logs came from. Also, bitrate of the video doesn't matter for this issue, I tried 1 mbps and 100 mbps, same result, after ~30 minutes it drops the connection.

xqq commented 7 years ago

Does the stream have an audio stream and A/V sync correctly?

rebelvg commented 7 years ago

Testing right now, will post results here in a ~10 minutes.

rebelvg commented 7 years ago

Nope, no A/V desync. Everything plays correctly. I'll do more testing with other browsers.

rebelvg commented 7 years ago

Tested yesterday on a live test server with real network connection on both FF and chrome. Couldn't reproduce this on chrome, only FF, but not consistently. Sometimes it played for 30 minutes and stopped, next time it played for almost 2 hours and didn't stop.

Seebomega commented 5 years ago

HI everyone same issue here randomly stops on FF with

[FlvPlayer] > MSE SourceBuffer is full, suspend transmuxing task

nguyenthanhduy91 commented 2 years ago

I have the same issue with FF [FlvPlayer] > MSE SourceBuffer is full, suspend transmuxing task Has someone fixed that problem yet?