Getting Started

JsSIP User Agent is the core element in JsSIP. It represents the SIP client associated to a SIP account. JsSIP User Agent is defined in JsSIP.UA class.

Multiple JsSIP User Agents can be created (this is useful for having different SIP accounts running in the same web application).

Creating a JsSIP User Agent

User Agent Configuration

JsSIP User Agent requires a configuration object for its initialization. There are some mandatory configuration parameters and many optional ones. Check the full configuration parameters list.

var configuration = {
  'ws_servers': 'ws://',
  'uri': '',
  'password': 'superpassword'

User Agent instance

var coolPhone = new JsSIP.UA(configuration);

User Agent events definition

Full list of User Agent events.

WebSocket connection events

coolPhone.on('connected', function(e){ /* Your code here */ });

coolPhone.on('disconnected', function(e){ /* Your code here */ });

New incoming or outgoing call event

coolPhone.on('newRTCSession', function(e){ /* Your code here */ });

New incoming or outgoing IM message event

coolPhone.on('newMessage', function(e){ /* Your code here */ });

SIP registration events

coolPhone.on('registered', function(e){ /* Your code here */ });
coolPhone.on('unregistered', function(e){ /* Your code here */ });
coolPhone.on('registrationFailed', function(e){ /* Your code here */ });

Starting the User Agent

See JsSIP.UA.start() method definition.


Making outbound calls

See method definition.


var session = null;

// HTML5 <video> elements in which local and remote video will be shown
var selfView =   document.getElementById('my-video');
var remoteView =  document.getElementById('peer-video');

// Register callbacks to desired call events
var eventHandlers = {
  'progress':   function(e){ /* Your code here */ },
  'failed':     function(e){ /* Your code here */ },
  'confirmed':  function(e){
    // Attach local stream to selfView
    selfView.src = window.URL.createObjectURL(session.connection.getLocalStreams()[0]);
  'addstream':  function(e) {
    var stream =;

    // Attach remote stream to remoteView
    remoteView.src = window.URL.createObjectURL(stream);
  'ended':      function(e){ /* Your code here */ }

var options = {
  'eventHandlers': eventHandlers,
  'extraHeaders': [ 'X-Foo: foo', 'X-Bar: bar' ],
  'mediaConstraints': {'audio': true, 'video': true}

session ='', options);

Instant messaging

See JsSIP.UA.sendMessage() method definition.

Example 1

var text = 'Hello Bob!';

coolPhone.sendMessage('', text);

Example 2

var text = 'Hello Bob!';

// Register callbacks to desired message events
var eventHandlers = {
  'succeeded': function(e){ /* Your code here */ },
  'failed':    function(e){ /* Your code here */ }

var options = {
  'eventHandlers': eventHandlers

coolPhone.sendMessage('', text, options);