jsmpeg
jsmpeg copied to clipboard
fixed bug with WebSocket constructor
Hi, i use your library for stream video by websockets from rtsp cam. I found and fixed the bug with 'new WebSocket(...)'.
Description: When you construct ws in Chrome like this 'new WebSocket('url', null)', Chrome thinks that protokol is not empty and sends header for that. So you should not pass this parameter if it has no value.
how Could you use websockets for an rtsp cam knowing that it's only TCP?
I wrote web server that gets rtsp from camera and translates it to websocket. And i got this error.
Will this be merged? I cannot get jsmpeg to work without this patch. It has been sitting here for a year without attention.
Until this fix is is merged, I have been able to stream video successfully on Chrome by manually specifying an empty subprotocol array as an option as follows:
Javascript API
new JSMpeg.Player( `ws://localhost:3001/ws/camera/stream?id=1`, {protocols: []})
HTML API
<div className="jsmpeg" data-protocols="[]"/>
An empty array isn't falsy and thus will not default to null in the WebSocket constructor, which is what Chrome seems to take issue with.
Should be fixed with https://github.com/phoboslab/jsmpeg/commit/3afb0e5df2ef0cc21512d956011b83325978686a