Stream Not received Server Side
See original GitHub issueHello, i’m trying tu use SimplePeer On a client/server based application sending Video/Audio Stream from the client browser to a NodeJs Server to perform some transformation or just record it !
Anyway , the library is a way instinctive and i want to use it instead of writing all the webrtc code client and server side !
The issue is that when the signaling process is done , i’m not receiving the Stream server side ! The code is the following : ///////////////////////////////////////////////////////////////////// Client //////////////////////////////////////////////////////////////////////////
let connection ;
let stream ;
function getWebSocket(){
var websocketEndpoint = 'ws://localhost:7000';
connection = new WebSocket(websocketEndpoint) ;
connection.onmessage = function (message){
p.signal(JSON.parse(message.data));
} ;
}
getWebSocket();
let p = null ;
function bindEvents(p){
p.on('signal' , function(data){
connection.send(JSON.stringify(data));
}) ;
p.on('error' , function(err){
console.log('error' , err);
}) ;
p.on('connect' , function(){
console.log("client connected");
})
}
document.querySelector('#start').addEventListener('click' , function(e){
navigator.getUserMedia({
video : true ,
audio : true
} , function(stream){
p = new SimplePeer({
initiator: true,
stream: stream ,
trickle : false
})
bindEvents(p);
} , function(err){
console.log(err);
})
})
///////////////////////////////////////////////////////////////////// Server Side //////////////////////////////////////////////////////////////////
'use strict';
var fs = require('fs');
var Peer = require('simple-peer')
var wrtc = require('wrtc') ;
var exec = require('child_process').exec;
var uuid = require('node-uuid');
function bindEvents(p , ws){
p.on('signal' , function(data){
ws.send(JSON.stringify(data));
}) ;
p.on('stream' , function(stream){
console.log("here we are buddy");
}) ;
p.on('error' , function(error){
console.log('erreur' , error) ;
}) ;
p.on('connect' , function(){
console.log("serveur connected");
})
}
module.exports = function (app) {
app.ws('/', function (ws, req) {
console.log('new connection established');
ws.on('message', function(data) {
var peer2 = new Peer({ trickle : false , wrtc: wrtc });
peer2.signal(JSON.parse(data));
bindEvents(peer2, ws) ;
});
});
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Assuming that if a stream was received my message “here we are buddy” must be logged ! What im i missing ? Is it related to some server configuration ? Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
For anyone stumbling over this thread:
node-webrtc
supports sending and receiving MediaStream objects Server-Side through its VideoSink and AudioSink interfaces: Just take a look at thevideo-compositing
example.Media streaming is not currently supported on Node.js server unfortunately, you can only use
RTCDataChannel
. For example, see readme here: https://github.com/js-platform/node-webrtcThere is nothing
simple-peer
can do about that, but as soon as there will be an implementation available innode-webrtc
or other project, it should be straightforward to get it supported insimple-peer
.