JSON-RPC module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”This module is an implementation of an JSON-RPC v2.0 client http://www.jsonrpc.org/specification. that can send a call to a JSON-RPC server over a TCP connection.
Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “OpenSIPS Modules”The following modules must be loaded before this module:
- none.
External Libraries or Applications
Section titled “External Libraries or Applications”The following libraries or applications must be installed before running OpenSIPS with this module loaded:
- none
Exported Parameters
Section titled “Exported Parameters”connect_timeout (integer)
Section titled “connect_timeout (integer)”The amount of milliseconds OpenSIPS waits to connect to the the JSON-RPC server, until it times out.
Default value is “500 milliseconds”.
...modparam("jsonrpc", "connect_timeout", 200)...write_timeout (integer)
Section titled “write_timeout (integer)”The amount of milliseconds OpenSIPS waits to send a RPC command to the JSON-RPC server, until it times out.
Default value is “500 milliseconds”.
...modparam("jsonrpc", "write_timeout", 300)...read_timeout (integer)
Section titled “read_timeout (integer)”The amount of milliseconds OpenSIPS waits for the JSON-RPC server to respond to a JSON-RPC request, until it times out. Note that these parameter only affects the jsonrpc_request command.
Default value is “500 milliseconds”.
...modparam("jsonrpc", "read_timeout", 300)...Exported Functions
Section titled “Exported Functions”jsonrpc_request(destination, method, params, ret_var)
Section titled “jsonrpc_request(destination, method, params, ret_var)”Does a JSON-RPC request to the JSON-RPC server indicated in the destination parameter, and waits for a reply from it.
This function can be used from any route.
The function has the following parameters:
- destination (string) - address of the JSON-RPC server. The format needs to be IP:port.
- method (string) - the method used in the RPC request.
- params (string) - these are the parameters sent to the RPC method. This parameter needs to be a properly formated JSON array, or JSON object, according the the JSON-RPC specifications.
- ret_var a writeable variable used to store the result of the JSON-RPC command. If the command returns an error, the variable will be populated with the error JSON, otherwise, with the body of the JSON-RPC result.
The function has the following return codes:
- 1 - JSON-RPC command executed successfully, and the server returned success. You can check the ret_pvar variable for the result.
- -1 - There was an internal error during processing.
- -2 - There was a connection (timeout or connect) error with the destination.
- -3 - The JSON-RPC was successfully run, but the server returned an error. Check the ret_pvar value to find out more information.
... if (!jsonrpc_request("127.0.0.1", "add", "[1,2]", $var(ret))) { xlog("JSON-RPC command failed with $var(ret)\n"); exit; } xlog(JSON-RPC command returned $var(ret)\n"); # parse $var(ret) as JSON, or whatever the function returns ...jsonrpc_notification(destination, method, params)
Section titled “jsonrpc_notification(destination, method, params)”Does a JSON-RPC notification to the JSON-RPC server indicated in the destination parameter, but unlike jsonrpc request, it does not wait for a reply from the JSON-RPC server.
This function can be used from any route.
The function receives the same parameters as jsonrpc request, except for the ret_pvar. Also, the same values are returned.
... if (!jsonrpc_notification("127.0.0.1", "block_ip", "{ \"ip": \"$si\" }")) { xlog("JSON-RPC notification failed with $rc!\n"); exit; } ...Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Razvan Crainea (@razvancrainea) | 16 | 7 | 932 | 13 |
| 2. | Stefan Darius (@dariusstefan) | 7 | 4 | 232 | 40 |
| 3. | Liviu Chircu (@liviuchircu) | 6 | 4 | 17 | 33 |
| 4. | Vlad Patrascu (@rvlad-patrascu) | 6 | 2 | 35 | 130 |
| 5. | Bogdan-Andrei Iancu (@bogdan-iancu) | 4 | 2 | 3 | 1 |
| 6. | Peter Lemenkov (@lemenkov) | 3 | 1 | 1 | 1 |
(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
(3) ignoring whitespace edits, renamed files and auto-generated files
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Mar 2018 - Jun 2026 |
| 3. | Vlad Patrascu (@rvlad-patrascu) | Apr 2019 - Apr 2019 |
| 4. | Bogdan-Andrei Iancu (@bogdan-iancu) | Dec 2018 - Apr 2019 |
| 5. | Liviu Chircu (@liviuchircu) | Apr 2018 - Nov 2018 |
| 6. | Peter Lemenkov (@lemenkov) | Jun 2018 - Jun 2018 |
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Vlad Patrascu (@rvlad-patrascu), Peter Lemenkov (@lemenkov), Liviu Chircu (@liviuchircu).
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0