sjkummer / janus-gateway-js

Janus-gateway WebRTC client for Node.js and the browser.
MIT License
172 stars 55 forks source link

Adding a valid SIP address emits error #104

Closed npafitis closed 4 years ago

npafitis commented 4 years ago

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.

sjkummer commented 4 years ago

Hi there,

I have clarified the basic usage example in the README.

  1. Make sure to have a Janus server running - including WebSocket support (see https://github.com/meetecho/janus-gateway/blob/master/README.md)
  2. Connect to your janus instance, e.g.:
var janus = new Janus.Client('ws://localhost:8188', {
  token: 'token',
  apisecret: 'apisecret',
  keepalive: 'true'
});