cycjimmy/jsmpeg-player

websocket connect with different backend server

joyhope opened this issue · 0 comments

Describe the bug
In html

`

<script type="text/javascript" src="statics/jsmpeg-player.umd.min.js"></script>
<script type="text/javascript">
var canvas = document.getElementById('video-canvas');
var url = 'ws://'+document.location.hostname+':8083/ws';
var player = new JSMpeg.Player(url, {canvas: canvas});
</script>

` The websocket without options.

But the websocket request will have
Sec-WebSocket-Protocol: null

For some kind of websocket server: python, golang, etc, I guess the null will send back, which caused chrome refused to make WebSocket connection.

Just make small change
if (this.options.protocols != null) { this.socket = new WebSocket(this.url, this.options.protocols); } else { this.socket = new WebSocket(this.url); }

So the null information will gone, it is much easy to used