proto_ws Module


Table of Contents

1. Admin Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. ws_port (integer)
1.3.2. ws_send_timeout (integer)
1.3.3. ws_max_msg_chunks (integer)
2. Frequently Asked Questions
3. Contributors
3.1. By Commit Statistics
3.2. By Commit Activity
4. Documentation
4.1. Contributors

List of Tables

3.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
3.2. Most recently active contributors(1) to this module

List of Examples

1.1. Set ws_port parameter
1.2. Set ws_send_timeout parameter
1.3. Set ws_max_msg_chunks parameter

Chapter 1. Admin Guide

1.1. Overview

The WebSocket protocol (RFC 6455) provides an end-to-end full-duplex communication channel between two web-based applications. This allows WebSocket enabled browsers to connect to a WebSocket server and exchange any type of data. RFC 7118 provides the specifications for transporting SIP messages over the WebSocket protocol.

The proto_ws module is transport module that provides communication over the WebSocket protocol. This module is fully compliant with the RFC 7118, thus allowing browsers to act as SIP clients for the OpenSIPS proxy.

The current implementation acts both as WebSocket server and client, thus it can accept connections from WebSocket clients and can also initiate connections to another WebSocket server. After the connection is established, messages can flow in both directions.

OpenSIPS supports the following WebSocket operations:

  • text and binary - can both send and receive WebSocket messages that contain text or binary body

  • close - messages used to safely close the WebSocket communication using a 2-messages handshake

  • ping - responds with pong messages. There is no mechanism to trigger ping messages.

  • pong - sent when a ping message is received. OpenSIPS, absorbes the pong messages received.

Once loaded, you will be able to define WebSocket listeners in your script. To add a listener, you have to add its IP, and optionally the listening port, after the mpath parameter, similar to this example:

...
mpath=/path/to/modules
...
listen=ws:127.0.0.1		# change with the listening IP
listen=ws:127.0.0.1:5060	# change with the listening IP and port
...

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • None.

1.2.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None.

1.3. Exported Parameters

1.3.1. ws_port (integer)

The default port to be used for all WS related operation. Be careful as the default port impacts both the SIP listening part (if no port is defined in the WS listeners) and the SIP sending part (if the destination WS URI has no explicit port).

If you want to change only the listening port for WS, use the port option in the SIP listener defintion.

Default value is 80.

Example 1.1. Set ws_port parameter

...
modparam("proto_ws", "ws_port", 8080)
...

1.3.2. ws_send_timeout (integer)

Time in milliseconds after a WebSocket connection will be closed if it is not available for blocking writing in this interval (and OpenSIPS wants to send something on it).

Default value is 100 ms.

Example 1.2. Set ws_send_timeout parameter

...
modparam("proto_ws", "ws_send_timeout", 200)
...

1.3.3. ws_max_msg_chunks (integer)

The maximum number of chunks in which a SIP message is expected to arrive via WebSocket. If a received packet is more fragmented than this, the connection is dropped (either the connection is very overloaded and this leads to high fragmentation - or we are the victim of an ongoing attack where the attacker is sending very fragmented traffic in order to decrease server performance).

Default value is 4.

Example 1.3. Set ws_max_msg_chunks parameter

...
modparam("proto_ws", "ws_max_msg_chunks", 8)
...

Chapter 2. Frequently Asked Questions

2.1.

Can OpenSIPS act as a WebSocket client?

Yes, starting with OpenSIPS 2.2, it can act as a WebSocket client.

2.2.

Does OpenSIPS support WebSocket message fragmentation?

No, WebSocket fragmentation mechanism is not supported.

Chapter 3. Contributors

3.1. By Commit Statistics

Table 3.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

 NameDevScoreCommitsLines ++Lines --
1. Razvan Crainea (@razvancrainea)75323884624
2. Liviu Chircu (@liviuchircu)642454
3. Bogdan-Andrei Iancu (@bogdan-iancu)53246
4. Vlad Paiu (@vladpaiu)4231
5. Ionut Ionita (@ionutrazvanionita)4222
6. Julián Moreno Patiño3111
7. Maksym Sobolyev (@sobomax)2130

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits. Regarding imported patches/code, we do our best to count the work on behalf of the proper owner, as per the "fix_authors" and "mod_renames" arrays in opensips/doc/build-contrib.sh. If you identify any patches/commits which do not get properly attributed to you, please submit a pull request which extends "fix_authors" and/or "mod_renames".

(3) ignoring whitespace edits, renamed files and auto-generated files

3.2. By Commit Activity

Table 3.2. Most recently active contributors(1) to this module

 NameCommit Activity
1. Razvan Crainea (@razvancrainea)Mar 2015 - May 2019
2. Bogdan-Andrei Iancu (@bogdan-iancu)Jun 2017 - Jun 2018
3. Liviu Chircu (@liviuchircu)Mar 2015 - Jun 2018
4. Maksym Sobolyev (@sobomax)Feb 2017 - Feb 2017
5. Julián Moreno PatiñoFeb 2016 - Feb 2016
6. Ionut Ionita (@ionutrazvanionita)Jul 2015 - Feb 2016
7. Vlad Paiu (@vladpaiu)Mar 2015 - May 2015

(1) including any documentation-related commits, excluding merge commits

Chapter 4. Documentation

4.1. Contributors

Last edited by: Bogdan-Andrei Iancu (@bogdan-iancu), Liviu Chircu (@liviuchircu), Razvan Crainea (@razvancrainea).

doc copyrights:

Copyright © 2015 www.opensips-solutions.com