Giter Club home page Giter Club logo

janus-gateway-js's Issues

Running on node?

I am having some trouble figuring out how to get this to work on node. I notice in your readme there are mentions of this throughout, but it seems like running on node needs some extra steps other than just do npm/yarn install. Could you write out some more detail instructions specifically for node?

It looks like I need to cd into the janus-gateway-js folder in node and run gulp? Then configure a third party webrtc adaptor? Is that correct for node use?

When using in node, no transaction ID is sent to Janus GW.

I tried the streaming.html example in the browser - and it works as expected.
When I use part of the code in a node.js application, the transaction ID is not sent and Janus GW throws an error ([(null)] Returning Janus API error 456 (Missing mandatory element (transaction))
).

browser:
{"janus":"attach","plugin":"janus.plugin.streaming","transaction":"ej4woril0g","session_id":509630889}

node.js:
{"janus":"attach","plugin":"janus.plugin.streaming","session_id":3989553632}

Code used:

var janus = new Janus.Client("ws://127.0.0.1:8188/janus/", {
    keepalive: true
});

janus.createConnection('client')
    .then(function(connection) {
        return connection.createSession();
    })
    .then(function(session) {
        return session.attachPlugin("janus.plugin.streaming");
    })

Does anybody know what might cause this?

How to restart the whole thing?

I have a Janus connection with the streaming plugin that works just fine.
It is all encapsulated in a function "init()". What I want to do is to restart init() when I get a ICE connection state change event that tells me we are disconnected. Basically I want to try to reconnect forever. I am no JS expert and am very new do promises. What would be a good way to do this? If I just start init() in the event listener, I end up with the old Janus object still running. I need to somehow shut everything down before restarting it.

function init() {
    var janus = new Janus.Client('address', {
	token: 'token',
	apisecret: 'apisecret'
    });

    janus.createConnection('id').then(function(connection) {
	connection.createSession().then(function(session) {
	    session.attachPlugin('janus.plugin.streaming').then(function(plugin) {
		plugin.watch(1).then(function(response){
		    var pc = plugin.getPeerConnection();
		    pc.oniceconnectionstatechange = function(event) {
			if (pc.iceConnectionState === "failed" || pc.iceConnectionState === "disconnected" || pc.iceConnectionState === "closed") {
			    // RESTART THE WHOLE THING HERE
			}
		    }
		});
		plugin.on('message', function(message) {});
	    });
	});
    });
}

Video resolution

Hello!

Is there any way to set the video resolution?
I'm trying to create a video room plugin.

According to the documentation, in order to set the video resolution we need to do something as follows:

...

function publishOwnFeed(useAudio) {
	// Publish our stream
	$('#publish').attr('disabled', true).unbind('click');
	sfutest.createOffer(
		{
			// Add data:true here if you want to publish datachannels as well
      media: { audioRecv: false, videoRecv: false, audioSend: useAudio, videoSend: true, video: "hires"},

....

The above piece of code is from janus videoroomtest.js file.
Note the video: "hires". In this case everything worked fine, the resolution of the video was 1280x720.

I tried to create something similar:

...

VideoRoomPlugin.prototype.processLocalVideo = function (info: JoinInfo) {
  let options = {audio: true, video: true}
  return new Promise(resolve => {
    this.getUserMedia(options)
      .then(stream => {
        this.createPeerConnection()
        stream.getTracks().forEach((track: MediaStreamTrack) => this.addTrack(track, stream))
      })
      .then(() => this.createOffer({media: {video: 'hires'}}))
      .then(jsep => this.configure(options, jsep))

...

But it didn't work, the resolution was the default (640x480)
Any help?

Adding a valid SIP address emits error

Trying to create a connection using this library this way

this.janusClient = new Janus.Client('sip:my-domain.com:5060');
    this.janusClient.createConnection('some_identity')
      .then(connection => {
        console.log(connection);
      })
      .catch(err => {
        console.log(err);
      });

and i get this error:

DOMException: Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'sip' is not allowed.
Error: Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'sip' is not allowed.
    at new W3CWebSocket (http://localhost:4300/vendor.js:291648:21)
    at http://localhost:4300/vendor.js:193132:21
    at Promise._execute (http://localhost:4300/vendor.js:160083:9)
    at Promise._resolveFromExecutor (http://localhost:4300/vendor.js:162224:18)
    at new Promise (http://localhost:4300/vendor.js:161820:10)
    at WebsocketConnection.open (http://localhost:4300/vendor.js:193131:10)
    at Connection.open (http://localhost:4300/vendor.js:190443:36)
    at Client.createConnection (http://localhost:4300/vendor.js:190333:21)
    at JanusService.push../src/app/soft-phone/shared/communication/janus.service.ts.JanusService.initialize (http://localhost:4300/main.js:89817:26)
    at CommunicationResolverService.push../src/app/soft-phone/shared/communication/communication-resolver.service.ts.CommunicationResolverService.initialize (http://localhost:4300/main.js:89665:35)
    at SafeSubscriber._next (http://localhost:4300/main.js:92714:40)
    at SafeSubscriber.__tryOrUnsub (http://localhost:4300/vendor.js:263956:16)
    at SafeSubscriber.next (http://localhost:4300/vendor.js:263894:22)
    at Subscriber._next (http://localhost:4300/vendor.js:263838:26)
    at Subscriber.next (http://localhost:4300/vendor.js:263815:18)
    at MapSubscriber._next (http://localhost:4300/vendor.js:269103:26)

Any help would be appreciated.

Support for REST http/https

From my knowledge this library only supports websocket connections, is it possible to add support for the REST api through http/https?

Note about processing `ack` event

Currently we don't complete transaction on ack https://github.com/cargomedia/janus-gateway-js/blob/f4ede2645f4a8c961cfd84f1d31564d456f45ba3/src/transactions.js#L52
Also ack events that are coming in response to plugin messages do not reach plugin level processing because they don't contain handle_id or sender fields. So, if you create a request from plugin and expect an ack response, you should expect it on plugin's session.
What shall we do with it? I don't know >_<

plugin.textroom issue

Hello All,

i succeeded to connect and attache to textroom plugin.

but i don't found a way to list rooms, it says that i am missing request data !!!

here is my code :

janus.createConnection('id').then(function(connection) {
  connection.createSession().then(function(session) {
    session.attachPlugin('janus.plugin.textroom').then(function(plugin) {
      plugin.send({
        "janus":"message",
        "body":{"request":"setup"}
      }).then(function(response){});
      plugin.send({
        "janus":"message",
        "body":{ "textroom":"list" }
      }).then(function(response){});
    });
  });
});

thanks

Docu for events

Currently we don't document all possible events from entities.

Deferred antipattern

#40 (comment)

Currently we have a deferred antipattern cause we promisify websocket communication. Zazabe please think about the more proper solution to it.

Data channel support (streaming plugin)

Hey Guys,
I need some help. I want to send a video stream with data channel over a LAN network to multiple clients.

For this I am using a very basic code template and the video stream is working, but i get no data over the data channel.
I added an event listener to the ondatachannel (see code below)

With the janus default demo I get data over the data channel. So my janus instance/config is hopefully not the problem.
Inside the streamingtest.js there is a streaming.createAnswer() option of: media: { audioSend: false, videoSend: false, data: true }

Do I miss this data: true maybe in the code below and how can i add this? I added it inside the watch() function but it has no effect.

I am new to Janus / WebRTC and currently somehow lost without concrete examples so I would really appreciate your help.
Thanks alot!!

   janus = new Janus.Client("ws://ipAddressOfJanusInstance:8188", {
        keepalive: "true",
      });

janus.createConnection("id").then(function (connection) {
  connection.createSession().then(function (session) {
    session.attachPlugin("janus.plugin.streaming").then(function (plugin) {
      plugin.watch(streamId, { audioSend: false, videoSend: true, data: true }).then(function (response) {
        let pc = plugin.getPeerConnection();

        pc.ondatachannel = function (event) {
          console.log(event); // not getting called
        };
      });

      plugin.on("pc:track:remote", function (event) {
        if (videoRef.current !== null)
          videoRef.current.srcObject = event.streams[0]; // getting called
      });

      plugin.on("message", function (response) {
        console.log(response); // getting called
      });
    });
  });
});

Move chromium installation script into this repo

Instead of having the build-specific installation procedure for Chromium in puppet-packages let's inline it here (like is already done for chromium web driver and npm install).

Then we can move the "workaround" 3ba5ebc1 into this script.

DataChannel support

I was wondering how to get Datachannels working with this client.
Do I just need to add this:

pc = plugin.getPeerConnection();
pc.ondatachannel = receiveChannelCallback;

or is some other initialization required?
(assuming that the plugin supports datachannels on the janus side)

npm run-script build doen't work.

Hello I'm newbie to janus!

I can't find any solution to this error so I leave the issue.

I try to build by npm run-script build, then the error is

'$' is not recognized as an internal or external command, operable program or batch file
npm ERR! code 1
npm ERR! path C:\Users\JH\Desktop\janus-gateway-js
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c "npm install && $(npm bin)/gulp "janus.js""

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\JH\AppData\Local\npm-cache\_logs\2021-02-19T03_23_38_208Z-debug.log

on WSL

The error is

Run `npm audit` for details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `npm install && $(npm bin)/gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jh/.npm/_logs/2021-02-19T03_37_57_751Z-debug.log

environment

npm : 7.0.3
os : windows 10

报这个错是什么原因

JanusError: Missing mandatory element (admin_key)
at http://127.0.0.1:5500/dist/janus.js:9999:17
at self._callback (http://127.0.0.1:5500/dist/janus.js:10479:27)
at Transaction.execute (http://127.0.0.1:5500/dist/janus.js:10504:20)
at Transactions.execute (http://127.0.0.1:5500/dist/janus.js:10572:24)
at StreamingPlugin.executeTransaction (http://127.0.0.1:5500/dist/janus.js:10432:35)
at StreamingPlugin.defaultProcessIncomeMessage (http://127.0.0.1:5500/dist/janus.js:10443:19)
at http://127.0.0.1:5500/dist/janus.js:9949:19
From previous event:
at Plugin.processIncomeMessage (http://127.0.0.1:5500/dist/janus.js:9944:9)
at http://127.0.0.1:5500/dist/janus.js:11189:64
From previous event:
at MediaPlugin.processIncomeMessage (http://127.0.0.1:5500/dist/janus.js:11188:21)
at Session.processIncomeMessage (http://127.0.0.1:5500/dist/janus.js:10199:37)
at Connection.processIncomeMessage (http://127.0.0.1:5500/dist/janus.js:9582:39)
at Connection. (http://127.0.0.1:5500/dist/janus.js:9427:10)
at EventEmitter.emit (http://127.0.0.1:5500/dist/janus.js:6066:22)
at WebsocketConnection.onMessage (http://127.0.0.1:5500/dist/janus.js:12097:10)
at WebsocketConnection. (http://127.0.0.1:5500/dist/janus.js:12008:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.