jsmpeg icon indicating copy to clipboard operation
jsmpeg copied to clipboard

fixed bug with WebSocket constructor

Open new-inventor opened this issue 5 years ago • 4 comments

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.

new-inventor avatar May 07 '19 14:05 new-inventor

how Could you use websockets for an rtsp cam knowing that it's only TCP?

ROBERT-MCDOWELL avatar May 14 '19 13:05 ROBERT-MCDOWELL

I wrote web server that gets rtsp from camera and translates it to websocket. And i got this error.

new-inventor avatar May 15 '19 06:05 new-inventor

Will this be merged? I cannot get jsmpeg to work without this patch. It has been sitting here for a year without attention.

Gronis avatar May 28 '20 19:05 Gronis

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.

1ttric avatar Jun 07 '20 00:06 1ttric

Should be fixed with https://github.com/phoboslab/jsmpeg/commit/3afb0e5df2ef0cc21512d956011b83325978686a

phoboslab avatar Sep 04 '22 18:09 phoboslab