Establish a connection with the Linphone SIP server using the SIP.js library

I am currently using the sip.js library from onsip.com as a web sip client. I was wondering if it is possible to establish a connection with the linphone sip service.

Code:

/* eslint-disable @typescript-eslint/no-explicit-any */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { UserAgentOptions, Web } from "sip.js";
import { SimpleUserDelegate } from "sip.js/lib/platform/web/simple-user/simple-user-delegate";
import { getButton, getE, getVideo } from "./scripts/demo-utils";

const domainOnSip = "sipjs.onsip.com";
export let webSocketServer="wss://edge.sip.onsip.com";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const domainLinphone = 'sip.linphone.org';
const webSocketServerLinphone="wss://sip.linphone.org";

const iamUser = "nidza";
webSocketServer = webSocketServerLinphone;

console.info('Hackey running...', Web);

const delegate: SimpleUserDelegate={
  onCallReceived: async () => {
    console.log('Incoming Call!');
    await simpleUser2.answer();
  }
};

const userAgentOptions = {
  sessionDescriptionHandlerFactoryOptions: {
    peerConnectionConfiguration: {
      iceServers: [{
        urls: "stun:stun.l.google.com:19302"
      }, {
        username: "nidza",
        credential: "***********"
      }]
    },
  }
};

// Options for SimpleUser
const options: Web.SimpleUserOptions={
  userAgentOptions: userAgentOptions,
  aor: `sip:${iamUser}@${domainLinphone}`,
  media: {
    constraints: { audio: false, video: true },
    local: {
      video: getVideo("videoLocalAlice")
    },
    remote: {
      video: getVideo("videoRemoteAlice")
    }
  }
};

const options2: Web.SimpleUserOptions={
  aor: `sip:zlatnaspirala@${domainLinphone}`,
  media: {
    constraints: { audio: false, video: true },
    local: {
      video: getVideo("videoLocalBob")
    },
    remote: {
      video: getVideo("videoRemoteBob")
    }
  },
  delegate: delegate
};


// Construct a SimpleUser instance
const simpleUser=new Web.SimpleUser(webSocketServer, options);
const simpleUser2=new Web.SimpleUser(webSocketServer, options2);

simpleUser.connect()
  .then(() => {

    console.info("status: sip server connected.");
    (getE('callIdList') as HTMLInputElement).disabled=false;
    (getButton('connectUser')).disabled=true;
    (getButton('registerUser')).disabled=false;

    simpleUser.register().then(() => {

      console.info("status: registered.");
      getButton('registerUser').disabled=true;
      getButton('callBtn').disabled=false;
      getButton('callBtn').classList.add('cooliano');
      getButton('callBtn').addEventListener('click', (e) => {

        console.log(">>>>"+(getE('callIdList') as HTMLSelectElement).selectedOptions[0].innerText)
        console.log(">>>>"+(getE('callIdList') as HTMLSelectElement).selectedIndex)
        const emailLocal=(getE('callIdList') as HTMLSelectElement).selectedOptions[0].innerText;

        const curAddress=`sip:${emailLocal}`;
        // const curAddress = `sip:bob@${domain}`;
        simpleUser.call(curAddress, undefined, {
          requestDelegate: {
            onAccept: (e) => {
              console.info(`status: ${(e as any).message.from.uri.normal.user} INVITE accepted from ${(e as any).message.to.uri.normal.user}`);
              getButton('hangupBtn').disabled=false;
              (getButton('hangupBtn')).addEventListener('click', () => {
                //

                simpleUser.hangup().then(() => {
                  console.log("just test hangup")
                })
              })
            },
            onReject: (response) => {
              console.info(`status: INVITE rejected`);
              let message=`Session invitation to  rejected.\n`;
              message+=`Reason: ${response.message.reasonPhrase}\n`;
              alert(message);
            }
          },
          withoutSdp: false
        })
          .catch((error: Error) => {
            console.error(`error: failed to begin session`, error);
            alert(` Failed to begin session.\n`+error);
          });
      })

    }).catch((error: Error) => {
      console.error("error in registration:", error);
    });

  }).catch((error: Error) => {
    console.error("error in connection:", error);
  });

simpleUser2.connect()
  .then(() => {
    simpleUser2.register().then(() => {
      console.log("Nice reg bob");
    }).catch((error: Error) => {
      console.log("Error in registration:", error);
    });
  }).catch((error: Error) => {
    console.log("Error:", error);
  });

transport.js:197 WebSocket connection to 'wss://sip.linphone.org/' failed: 
_connect @ transport.js:197
logger-factory.js:85 Sat Jan 07 2023 21:23:45 GMT+0100 (Central European Standard Time) | sip.Transport | WebSocket error occurred.
print @ logger-factory.js:85
hackeyWeb.ts:108 error in connection: Error: WebSocket closed wss://sip.linphone.org (code: 1006)
    at Transport.onWebSocketClose (transport.js:337:1)
    at WebSocket.<anonymous> (transport.js:199:1)

Do you have any suggestions or ideas on how to troubleshoot this issue?

Answer №1

Unfortunately, flexisip does not have support for websockets at this time.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clearing all data in a form upon opening

Within a single portlet, I have organized two forms under separate tabs. What I am aiming for is that whenever I switch to tab 2, all fields within its associated form should automatically be cleared without the need for a button click. Even after attempti ...

What is the best way to limit an input field to only allow up to two decimal places and a maximum of 10 total

Is there a way to limit an input field to only accept two decimal places and have a maximum of 10 digits? I have implemented a function that is triggered by the onkeypress event and checks the length of the value entered into the input field. I have manag ...

The sequence of Request and Response in Express

When using the Express app.get() method, does the order of writing response and request matter? For example, is there a difference between app.get("/", (req, res) => and app.get("/", (res, req) =>? ...

"Utilizing a range input element with a set value on the slider

I have implemented the input type range property on my webpage and have applied some CSS styling to it. However, I feel like there is room for improvement. .Slider { -webkit-appearance: none; width: 75%; height: 15px; border-radius: 5px; backg ...

Exploring methods of testing a simple React functional component using Jest, TypeScript, and type annotations

I have been struggling for a long time to find a straightforward example of how to test a simple react component using jest and typescript. Despite my efforts, I have not been successful in finding a solution. I have checked out: https://basarat.gitbooks.i ...

Guide on showcasing an array of objects in HTML with the help of the template element

My goal was to populate the HTML page with an array of objects using the template element. However, I made a mistake and only the last object in the array was displayed correctly on the page. Can anyone help me identify my error and suggest a correction? I ...

Prevent Angular from automatically scrolling to the top when subscribing to a timer

I have a real-time updating list of orders that is scrollable. This is the main component, where the list gets updated every 2 minutes with the following setup: ngOnInit(): void { this.internalError = false; this.subscription = timer(0, 120 * 1000) ...

AngularJS Services and Factories that are loaded at startup rather than on-demand

Having an issue with my AngularJS application. I have defined some factories that are injected into controllers as needed. The problem is that these factories are initialized when the application first starts up. One problematic service is: PlanningPoker ...

Executing a function in ExpressJS at regular intervals of 24 hours

Can someone share the most effective method to schedule an automated task every 24 hours in ExpressJS? I have thoroughly researched possible solutions but haven't found any option other than using an infinite loop. Is there only one way to achieve th ...

Changing the size of text using radio buttons in JQuery MobileIs there a way to modify

I am currently working on adjusting the text size for both header and paragraph information in a listview. Below is the JQuery code that I have implemented: $('#rc1').prop('checked', 'true', function(){ $(".feedContainer ...

Issue with importing and exporting JavaScript on an HTML file is not functioning as expected

I recently worked on a basic JavaScript project involving export/import and encountered an error when inserting it into the HTML. The error message read: "Uncaught SyntaxError: Cannot use import statement outside a module". I researched this issue on Stack ...

Timing feature utilized in a Web Application

My latest project involves developing a web-based testing application using CakePHP. Here's how it works: when a user starts a test, the exact start time is stored on the web server. Once the test is completed and the answers are submitted, the serve ...

Having trouble installing the 'ws' npm package on MacOS Big Sur?

Every time I try to install the websocket package using "npm install ws", I keep getting this error message: npm ERR! code ENOSELF npm ERR! Refusing to install package with name "ws" under a package npm ERR! also called "ws". Did you name your project the ...

How can Angular be used to fetch the name associated with a user_id in Laravel?

There seems to be a problem with fetching the name attribute along with the title and body attributes. The name appears empty on page refresh but shows up automatically upon submission. Interestingly, angularjs is unable to retrieve the name successfully. ...

When attempting to open a popup form by clicking a button, the code fails to function on IE6

Everything seems to be running smoothly on Firefox, however I am encountering issues with Internet Explorer 6. Here is a snippet of the problematic code: document.getElementById('layout').style.opacity = .7 document.getElementById('layout&a ...

Highlighting neighboring components with the same marker when hovering in Slate JS: a step-by-step guide

// custom mouse over hook function useMouseOver() { const [mouseIsOver, setMouseIsOver] = useState(false); return { mouseIsOver, triggers: { onMouseEnter: () => setMouseIsOver(true), onMouseLeave: () => setMouseIsOver(false), ...

What separates a typical update from using the $set operator for updating?

Standard procedure: module.exports = (_id, newInfo) => { return User.update( {_id} , newInfo); }; Alternative approach with $set operator: module.exports = (_id, newInfo) => { return User.update( {_id} , {$set: newInfo} ); }; ...

Modify the div's visibility based on selected option in the dropdown menu

In my PHP file, I have the following codes: <section id="placeOrder"> <h2>Place order</h2> Your details Customer Type: <select name="customerType"> <option value="">Customer Type?</option> <option value="ret ...

Delay the execution of Javascript code for one hour daily over the course of a month

Updated Question: Despite the larger issue, can someone explain why the sleep function in the code below doesn't provide a one-hour pause in execution? Understanding this would be greatly appreciated. I am trying to trigger a JavaScript function that ...

Preference for executing multiple dependent ajax calls synchronously

There are various approaches to handling multiple dependent ajax synchronous calls, but two of the most commonly used methods are the jQuery defer method and using callbacks on success. My inquiries include: 1) What are the benefits of utilizing one me ...