webcast / webcast.js

API and documentation for the webcast websocket protocol
MIT License
79 stars 26 forks source link

Add the ablity to restart broken connection. #26

Closed smimram closed 2 years ago

smimram commented 2 years ago

With the webcam example (#25), liquidsoap's harbor sometimes stops with

2022/08/25 11:07:54 [input.harbor_0:2] Feeding stopped: Ffmpeg_decoder.End_of_file.

and in the browser's console we get

The connection to ws://localhost:8000/mount was interrupted while the page was loading.

Webcast.js should provide a simple way to catch websocket's errors and initiate a new connection.

toots commented 2 years ago

The underlying websocket should be present on the webcast's instance:

webcast.socket.on("error", ...);
webcast.socket.on("close", ...);

Is that enough for you?

smimram commented 2 years ago

The thing is that most of the connection stuff is performed by the constructor, which makes it uneasy to reconnect. Let me propose something to you...

smimram commented 2 years ago

Actually the main problem is that we cannot catch error performed when constructor's code is executed. I propose #27 to solve this.