question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stream Not received Server Side

See original GitHub issue

Hello, 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:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
seandlgcommented, Sep 2, 2019

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 the video-compositing example.

1reaction
nazar-pccommented, Apr 19, 2018

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-webrtc

node-webrtc provides Node.js bindings to WebRTC M60. You can write Node.js applications that use RTCDataChannels with it. MediaStream APIs are not supported at this time.

There is nothing simple-peer can do about that, but as soon as there will be an implementation available in node-webrtc or other project, it should be straightforward to get it supported in simple-peer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Sent Events not receiving messages from stream with ...
I can see that stream was opened but none event was passed from the server, while data was issued on the server side....
Read more >
Problem with server side event str… | Apple Developer Forums
My app responds to incoming server side event stream when in the foreground but not while in the background. Can someone point me...
Read more >
Server side aborted request in stream mode hang with node ...
Server side aborted requests in stream mode conduce got to hang with node >= 14.3.0. In fact the aborted event from the IncomingMessage...
Read more >
Streaming Server-Side Rendering - Patterns.dev
The function will only work on the server to render HTML as a stream. The client receiving this stream can subsequently call ReactDOM....
Read more >
Using server-sent events - Web APIs | MDN
The server-side script that sends events needs to respond using the MIME type text/event-stream . Each notification is sent as a block of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found