langhuihui / jessibuca

Jessibuca是一款开源的纯H5直播流播放器
https://jessibuca.com
GNU General Public License v3.0
2.07k stars 398 forks source link

远程 http-flv 服务器关闭后,不刷新网页如何实现自动重连? #280

Closed rockcarry closed 1 year ago

rockcarry commented 1 year ago

配置了如下参数: loadingTimeout: 5, loadingTimeoutReplay: true, loadingTimeoutReplayTimes: -1, heartTimeout: 5, heartTimeoutReplay: true, heartTimeoutReplayTimes: -1, wasmDecodeErrorReplay: true, 如果服务器只是短时间关闭然后重新恢复,不刷新页面,是可以自动重新播放的。

但是如果服务器关闭较长时间,然后重新恢复,则自动重新播放会失败,浏览器 console 输出如下 log:

Jessibuca: [player events] kBps 54.23 jessibuca.js:1 GET http://localhost:8080/live.flv net::ERR_CONNECTION_RESET 200 fetchStream @ jessibuca.js:1 (anonymous) @ jessibuca.js:1 Promise.then (async) (anonymous) @ jessibuca.js:1 play @ jessibuca.js:1 (anonymous) @ jessibuca.js:1 r @ jessibuca.js:1 emit @ jessibuca.js:1 decoderWorker.onmessage @ jessibuca.js:1 jessibuca.js:1 Jessibuca: [player events] error fetchError jessibuca.js:1 Jessibuca: [AudioContext] bufferList is large: 21 warn @ jessibuca.js:1 play @ jessibuca.js:1 decoderWorker.onmessage @ jessibuca.js:1 jessibuca.js:1 Jessibuca: [player events] stats {buf: 201, fps: 13, abps: 961, vbps: 11177, ts: 15047116} jessibuca.js:1 Jessibuca: [player events] performance 0 jessibuca.js:1 Jessibuca: [player events] stats {buf: 201, fps: 0, abps: 0, vbps: 0, ts: 15047116} jessibuca.js:1 Jessibuca: [player events] performance 0 jessibuca.js:1 Jessibuca: [player events] stats {buf: 201, fps: 0, abps: 0, vbps: 0, ts: 15047116} jessibuca.js:1 Jessibuca: [player events] performance 0 jessibuca.js:1 Jessibuca: [FetchStream] destroy jessibuca.js:1 Jessibuca: [CommonDemux] destroy jessibuca.js:1 Jessibuca: [FlvDemux] destroy jessibuca.js:1 Jessibuca: [decoderWorker] destroy decoder.js:1 Jessibuca: [worker]: close jessibuca.js:1 Jessibuca: [AudioContext] destroy jessibuca.js:1 Jessibuca: [player events] playing false jessibuca.js:1 Jessibuca: [player events] volumechange 0 jessibuca.js:1 Jessibuca: [player events] pause undefined jessibuca.js:1 Jessibuca: [player events] timeout delayTimeout jessibuca.js:1 Jessibuca: [player events] delayTimeout undefined jessibuca.js:1 Jessibuca: [Jessibuca] delay timeout replay time is 0 jessibuca.js:1 Jessibuca: [player events] loading true jessibuca.js:1 Jessibuca: [FetchStream] init jessibuca.js:1 Jessibuca: [AudioContext] init jessibuca.js:1 Jessibuca: [common dumex] init Interval jessibuca.js:1 Jessibuca: [FlvDemux] init jessibuca.js:1 Jessibuca: [decoderWorker] init decoder.js:1 GET http://localhost:8080/decoder.js net::ERR_CONNECTION_REFUSED 200

从 log 看是触发了自动重连机制,但是重连的时候,无法从服务器获取 decoder.js 这个文件,然后就一直没有继续重连的尝试了。 只能刷新页面才能恢复正常。

想知道这个问题如何解决?

bosscheng commented 1 year ago

‘decoder.js:1 GET http://localhost:8080/decoder.js net::ERR_CONNECTION_REFUSED 200’ 服务器都被你停到了,资源都请求不到了。你关闭 flv 服务器 别把静态资源也一起关掉啊。

rockcarry commented 1 year ago

‘decoder.js:1 GET http://localhost:8080/decoder.js net::ERR_CONNECTION_REFUSED 200’ 服务器都被你停到了,资源都请求不到了。你关闭 flv 服务器 别把静态资源也一起关掉啊。

我就是想处理这种服务器彻底停掉的情况。我们的设备是嵌入式设备,有能直接断电。如果设备重新上电,能否不刷新页面,就能继续重连出流?

bosscheng commented 1 year ago

那你得保证静态资源能被请求访问到吧。不行你就把静态资源单独放一个path下面,因为触发重新播放流,会重新初始化worker解码器,必然的会触发重新请求decoder.js 和decoder.wasm文件的。

这样讲你懂我的意思吧,流的服务器停掉没问题,保证静态资源能被访问到。