{"id":11188,"library":"jssip","title":"JsSIP","description":"JsSIP is a robust and lightweight JavaScript SIP library that enables real-time communication capabilities in both browser and Node.js environments. It currently maintains version 3.13.6, with a steady release cadence indicating active development and timely updates. The library facilitates SIP over WebSocket (RFC 7118, co-authored by JsSIP's creators), supporting audio/video calls via WebRTC, and instant messaging. Its key differentiators include its dual-environment compatibility, a user-friendly yet powerful API, and demonstrated interoperability with popular SIP servers like Kamailio, Asterisk, and Mobicents. JsSIP provides a flexible foundation for integrating SIP functionality directly into web applications, abstracting the complexities of WebRTC and WebSocket signaling for developers.","status":"active","version":"3.13.6","language":"javascript","source_language":"en","source_url":"https://github.com/versatica/JsSIP","tags":["javascript","sip","websocket","webrtc","node","browser","library","typescript"],"install":[{"cmd":"npm install jssip","lang":"bash","label":"npm"},{"cmd":"yarn add jssip","lang":"bash","label":"yarn"},{"cmd":"pnpm add jssip","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While CommonJS `require` works for the UMD bundle, modern applications and TypeScript projects should prefer the ESM named or namespace imports. JsSIP ships both CJS and ESM bundles.","wrong":"const JsSIP = require('jssip');","symbol":"JsSIP","correct":"import * as JsSIP from 'jssip';"},{"note":"UA is a named export, not the default export. Accessing it via the global `JsSIP.UA` is also common when JsSIP is loaded as a script without a module bundler.","wrong":"import UA from 'jssip';","symbol":"UA","correct":"import { UA } from 'jssip';"},{"note":"The class is specifically named `WebSocketInterface`. Ensure correct capitalization and the full name.","wrong":"import { WSI } from 'jssip';","symbol":"WebSocketInterface","correct":"import { WebSocketInterface } from 'jssip';"}],"quickstart":{"code":"import { UA, WebSocketInterface } from 'jssip';\n\nconst socket = new WebSocketInterface('wss://sip.myhost.com');\nconst configuration = {\n  sockets  : [ socket ],\n  uri      : 'sip:alice@example.com',\n  password : process.env.SIP_PASSWORD ?? 'superpassword' // Use environment variables for sensitive data.\n};\n\nconst ua = new UA(configuration);\n\nua.start();\n\n// Register callbacks to desired call events\nconst eventHandlers = {\n  'progress': (e: any) => { // Type 'any' for brevity; consider defining specific event types\n    console.log('Call is in progress');\n  },\n  'failed': (e: any) => {\n    console.error('Call failed with cause: ' + e.data.cause);\n  },\n  'ended': (e: any) => {\n    console.log('Call ended with cause: ' + e.data.cause);\n  },\n  'confirmed': (e: any) => {\n    console.log('Call confirmed');\n  }\n};\n\nconst options = {\n  eventHandlers,\n  mediaConstraints: { 'audio': true, 'video': true }\n};\n\nconst session = ua.call('sip:bob@example.com', options);\n\n// Example: Stop UA after some time (for demonstration)\nsetTimeout(() => {\n  console.log('Stopping User Agent...');\n  ua.stop();\n}, 30000);","lang":"typescript","description":"This quickstart demonstrates how to instantiate a JsSIP User Agent, configure a WebSocket transport, register event handlers for the call lifecycle, and initiate an audio/video SIP call. It showcases the fundamental setup required for WebRTC-based communication using JsSIP in a modern JavaScript/TypeScript environment, including proper import syntax and basic error handling."},"warnings":[{"fix":"Migrate your media handling logic to explicitly manage `MediaStream` objects obtained from `RTCSession` events and attach them to `<video>` or `<audio>` elements in the DOM. Consult `JsSIP.RTCSession` documentation for details.","message":"In JsSIP 0.3.x, HTML5 video elements are no longer directly handled by JsSIP. Developers must now use media stream handling tools to decide when and where to attach local and remote media streams, offering more control but requiring manual DOM manipulation for media elements.","severity":"breaking","affected_versions":"0.3.x"},{"fix":"Ensure your SIP over WebSocket server is configured with a publicly trusted SSL/TLS certificate from a recognized Certificate Authority (CA) for production. For development, you may need to explicitly trust self-signed certificates in your browser or OS, or temporarily use non-secure `ws://` if appropriate.","message":"When using secure WebSocket (WSS) connections for SIP signaling, the server must present a valid, publicly trusted SSL/TLS certificate. Browsers will reject connections to servers with self-signed, expired, or untrusted certificates, leading to `WebSocket connection failed` errors in the console.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement robust UI/UX to proactively prompt users for media permissions. Gracefully handle permission denials by informing the user and guiding them on how to grant permissions via browser or operating system settings. Always check `navigator.mediaDevices.getUserMedia` promises for rejection.","message":"Browsers require explicit user consent to access the microphone and camera. If a user denies these permissions, JsSIP calls configured with `mediaConstraints` will fail with a `NotAllowedError` or `Permission denied` DOMException, preventing media capture.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that your SIP server (e.g., Kamailio, Asterisk, Mobicents) has a WebSocket listener enabled and properly configured for the correct path and port, with TLS/SSL correctly set up if using WSS. Check server logs and network activity in browser developer tools for connection errors.","message":"JsSIP relies on a SIP server correctly configured to support SIP over WebSocket (RFC 7118). Common misconfigurations include incorrect WebSocket path, missing TLS setup for WSS, or firewall blocks, which will prevent the JsSIP `UA` from establishing a connection.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to JsSIP 3.2.17 or later, which includes changes to switch to `MediaStreamTrack` from the deprecated `MediaStream` API. If using older versions, ensure `webrtc-adapter` is properly included and up-to-date in your application.","message":"JsSIP versions prior to 3.2.17 might use deprecated `MediaStream` API methods for WebRTC. Modern browser versions have transitioned to `MediaStreamTrack` APIs. While `webrtc-adapter` can help, directly supporting `MediaStreamTrack` is essential for compatibility.","severity":"breaking","affected_versions":"<3.2.17"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Inspect your browser's developer console for more specific WebSocket errors. Verify your SIP server's SSL/TLS certificate is valid and trusted. Confirm the WebSocket server is running and accessible on the specified URL and port, and that firewalls are not blocking the connection.","cause":"This error frequently indicates issues with the SIP WebSocket server's SSL/TLS certificate (if using WSS), the server being unreachable, or a misconfigured WebSocket endpoint.","error":"WebSocket connection to 'wss://...' failed: WebSocket is closed before the connection is established."},{"fix":"Guide the user to grant media permissions. Advise them to check their browser's site settings (e.g., camera and microphone permissions) and operating system privacy settings. Consider providing a UI element to trigger the permission prompt again.","cause":"The user's browser or operating system has blocked access to the microphone or camera, which is required for the call's `mediaConstraints`.","error":"NotAllowedError: Permission denied by system"},{"fix":"Ensure the `UA` instance is correctly configured and `ua.start()` is called and has had time to establish its connection before `ua.call()` is invoked. Check for errors during `ua.start()` and related event handlers (`registered`, `unregistered`, `registrationFailed`).","cause":"`ua` (User Agent) instance might not be properly initialized or `ua.start()` has not completed successfully before attempting to make a call.","error":"TypeError: Cannot read properties of undefined (reading 'call')"},{"fix":"Review the SIP URI string (`sip:bob@example.com` in the quickstart) to ensure it adheres to the correct SIP URI syntax (e.g., `sip:user@host` or `sips:user@host`). Avoid common typos or missing components.","cause":"The provided SIP URI format for calling or configuring the User Agent is incorrect or malformed according to SIP URI specifications.","error":"Error: Invalid URI 'sip:user@domain.com'"}],"ecosystem":"npm"}