Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket connect with different backend server #99

Open
joyhope opened this issue May 28, 2022 · 0 comments
Open

websocket connect with different backend server #99

joyhope opened this issue May 28, 2022 · 0 comments

Comments

@joyhope
Copy link

joyhope commented May 28, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant