ScarletsFiction / SFMediaStream

HTML5 media streamer library for playing music, video, playlist, or even live streaming microphone & camera with node server
MIT License
102 stars 30 forks source link

group-call help #12

Open Mariusz731 opened 4 years ago

Mariusz731 commented 4 years ago

Hi Your project is very interesting, but I can't use it because of my poor knowledge. I am beginner in nodejs, but I need tool for streaming speaker (browser/microphone) voice to another users (browsers) by nodejs server. I have just run Your example group-call and got errors: The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. WebSocket connection to 'ws://omisoft.pl/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 404 The first is I guess not SSL connection, but the second error is too dificult for me to resolve. I don't know how use Your code in SSL mode. If You have an advice and time for help I am ready to pay for it.

Mariusz Urban

StefansArya commented 4 years ago

The warning about AudioContext is not a problem I think, as the library is trying to obtain browser's AudioContext after the user interacted with the page.

It seems the WebSocket server was not found, maybe the Node.js server haven't been started or the port number was different. If you're using the example (that run the server on port 8000) the WebSocket server will also available on port 8000. But if you're using Nginx or Apache to serve your website on port 80, then you need to change Socket.IO to connect the WebSocket server on port 8000.

https://github.com/ScarletsFiction/SFMediaStream/blob/77e9ef53029fbad49fdf9b7fdcdba70c20080529/example/group-call/browser/socket.js#L1-L6

The first line should be changed into io("http://domain.com:8000", {transports:['websocket']});

If you want to use HTTPS or SSL, you need to modify line 4 on the server.js https://github.com/ScarletsFiction/SFMediaStream/blob/77e9ef53029fbad49fdf9b7fdcdba70c20080529/example/group-call/server.js#L3-L5

with below

var fs = require('fs');
var server = require('https').createServer({
    key: fs.readFileSync('privatekey.pem'),
    cert: fs.readFileSync('certificate.pem')
}, app)

or following from Socket.IO's documentation. If you're proxying the WebSocket server through Nginx, the story would be little different.

Thanks for your interest to contribute. But I still have to finish my thesis and some projects, my response may be slow..

Mariusz731 commented 4 years ago

Thank You very much! I will try to do it. Normally I write code in PHP, but Your code is very clear even for me. Best Regards!

Mariusz731 commented 4 years ago

Hi,

I didn't want to waste Your time and tried to do something all day. It is my battle since our last contact - without result. I have no idea. It seems to be a problem out of Your project. Maybe You will find a while during a coffee :)

/browser/ var socket = io("https://omisoft.pl:3000", {transports:['websocket'],secure: true});

/server/ var server = require('https').createServer({ key: fs.readFileSync('key.pem', 'utf8'), cert: fs.readFileSync('cert.pem', 'utf8') }, app); ... io.listen(app.listen(3000));

And permanently: index.js:83 WebSocket connection to 'wss://omisoft.pl:3000/socket.io/?EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

Key, cert was created by openssl command (node.js main site) WWW server is Apache. Without https browser doesn't work properly.

Best Regards Mariusz Urban

StefansArya commented 4 years ago

Looks like the URL was exist, but the problem is on the SSL's certificate.. Maybe it's invalid or not being loaded by Node.js, or maybe the browser was rejected the untrusted SSL certificate.

Instead of using .pem you can use .key for the key, public or fullchain .crt for the cert. Maybe generate it with Let's Encrypt, and test it from SSLLabs.

The SSL certificate that generated from Let's Encrypt is free, and some browser would trust it..

Mariusz731 commented 4 years ago

Thank You for the answer. I realized 20$ donation few hours ego. Your advices are very usefull. I have done PHP project for special and impatient :) clients. They want to have voice :) I need only one Presenter and many Listeners (by broadcast) with possibility to change Listener to Presenter. I think Your group-call app would be perfect tool. I will try to check Your advice with Let's Encrypt. If I finish my project successfull, I will appreciate Yor project and knowledge. Best regards and thanks for all

StefansArya commented 4 years ago

You're welcome. If this was your first experience then it would difficult to find where to start so I would suggest Certbot's instruction for getting started.

But if you want a shortcut then you can generate via online service. Well, this discussion is a bit out of topic, but thanks anyway for donation 😄 .