OpenSIPS / opensips-cp

A Web Control Panel Application for the OpenSIPS, which is intended for both system and user provisioning. It features more than 18 tools, covering important functionalities (MI,statistics) and modules (acc,siptrace,drouting,dialplan) of OpenSIPS.
GNU General Public License v2.0
113 stars 78 forks source link

Dispatcher ds_set_state Invalid param partition #296

Closed Integration-IT closed 2 months ago

Integration-IT commented 3 months ago

Dispatcher menu, memory state. When memory state would be changed from "GREEN" state to "RED" state to isolate the destination, the MI command transmits an invalid state as a capital "i" like "Active" state.

Let's try to disable manually from opensips-cli and inspect the log request:

 DBG:mi_fifo:mi_fifo_callback: running command [{"jsonrpc": "2.0", "id": "24285", "method": "ds_set_state", "params": {"state": "0", "group": "1", "address": "sip:x.x.x.x:5060"}}]

result: DB state is Inactive and memory state is red.

Let's try to enable manually from opensips-cli and inspect the log request:

DBG:mi_fifo:mi_fifo_callback: running command [{"jsonrpc": "2.0", "id": "2244", "method": "ds_set_state", "params": {"state": "1", "group": "1", "address": "sip:x.x.x.x:5060"}}]

result: DB state is Active and memory state is green.

Finally, let's try to disable a destination from dispatcher control panel (Memory State section) and inspect the MI request:

DBG:httpd:answer_to_connection: got ContentType [3] with len [138]: {"jsonrpc":"2.0","id":1,"method":"ds_set_state","params":{"state":"I","group":"1","address":"sip:x.x.x.x:5060","partition":"default"}}
DBG:mi_http:mi_http_run_mi_cmd: got command=ds_set_state
ERROR:core:handle_mi_request: Invalid parameters

The issue could be here : change state section. Before modify the state, the actual state is stored as $desired_state = 'I'; and this result should not be reuse to set the new val but the opposite one instead.

Integration-IT commented 3 months ago

After extra tests, "I" and "A" are relevant but the last partition could be not.

(cli): mi ds_set_state (TAB)
address=  group=    state=
...
(cli): mi ds_set_state state=I group=1 address=sip:x.x.x.x:5060
"OK"
(cli): mi ds_set_state state=A group=1 address=sip:x.x.x.x:5060
"OK"
(cli): mi ds_set_state state=A group=1 address=sip:x.x.x.x:5060 partition=default
ERROR: command 'ds_set_state' returned: -32602: Invalid params (Too few or too many parameters)

The dispatcher.php would like pass it whatever

DBG:httpd:answer_to_connection: got ContentType [3] with len [138]: {"jsonrpc":"2.0","id":1,"method":"ds_set_state","params":{"state":"I","group":"1","address":"sip:x.x.x.x:5060","partition":"default"}}
DBG:mi_http:mi_http_run_mi_cmd: got command=ds_set_state
ERROR:core:handle_mi_request: Invalid parameters

$params["partition"] = $dispatcher_partition;

bogdan-iancu commented 3 months ago

Have you properly configure the dispatcher_partition setting in the dispatcher tool ?