Skip to main content

WebRTC with SIP Over WebSockets

SignalWire supports industry-standard WebRTC SIP over WebSockets! This means that you can use off-the-shelf JavaScript libraries with SIP to connect to SignalWire services.

Services enabled in a WebRTC compliant browser include:

  • Audio calling to/from Web and PSTN
  • product:video calling between Web and SIP endpoints
  • Programmatically creating SIP endpoints and directing calls to your WebRTC endpoints

To get started, navigate to your SignalWire Space and create a new SIP endpoint. To use secure protocols, make sure the Encryption is required.

Now, you can test the newly created endpoint on a popular JS SIP (JSSIP) library:

A screenshot of the TryIt JS SIP interface. In the 'Your Name' input field, the user has entered 'jssip1'. There is a gear icon and a button labeled 'Reset'.

If you click the gear icon, you can configure the settings needed to connect to SignalWire. The SIP URI is your SignalWire SIP username and domain. The password set on your SIP endpoint can be used in the SIP password section to authenticate. The WebSocket URI is your domain with an appended wss://. To match the encryption on SignalWire, set the transport to TLS. The Registrar Server should be set to your domain.

A screenshot of the JsSIP UA settings pane, with fields for SIP URI, SIP Password, WebSocket URI, Via Transport, and Registrar Server.

Once you've saved the entered information, you will see the endpoint register and turn from yellow to green as it appears below:

A screenshot of the TryIt JsSIP interface showing a registered endpoint with a green dot.

Then, set up another SIP endpoint with the same process as above:

A screenshot of the TryIt JsSIP interface showing a second registered endpoint.

Now that both of the endpoints are registered, you can place the first call. If you're using SIP endpoints in the same project, you can use short-hand names (for example, jssip1 and jssip2 as seen in the images above) to place the call:

A screenshot of the TryIt JsSIP interface showing a green dot next to the jssip2 endpoint. In the field labeled 'SIP URI or username', the endpoint named jssip1 has been entered. A blue button is labeled 'Call'.

If everything was set up correctly, you should see something similar to this:

A screenshot of the TryIt JsSIP interface showing a working video call.

In addition, you can attribute a phone number to your created sip endpoint and receive calls from the PSTN! You can also place the outbound calls to the PSTN from the WebRTC client.

A screenshot of the JsSIP interface showing an incoming call. The call is from a PSTN phone number associated with a SIP endpoint, so both are shown. Buttons underneath allow the user to Answer or Reject the call.