Table of Contents
List of Examples
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,
mpath parameter, similar to this
... 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 ...
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.
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.
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.