RPC ubus unable to call methods of custom object

I've create a service using ucode which creates a new ubus object with some methods.
Accessing those methods thru ubus cli works like a charm.

Now I want to access it over http (I'm using nginx ubus plugin). I do can login with root user or custom created users within rpcd config. But if I then try to call one of the methods of my object, I get this in the result prop of JSON RPC response: [2].

Calling another method like system.board does work.

I've tried to find what is the 2 error code with no luck.
The root user and the other user have read and write * access, I've tried many different ACL definitions within /usr/share/rpcd/acl.d/*.json, specific for my functions as well as * ones... with no luck.

Any idea what's going on?
Also is there a way to enable verbose logging of rpcd?

This needs to be moved to the "For Developers" section where it may get more attention.

done, thanks!

1 Like

Code 2 is UBUS_STATUS_INVALID_ARGUMENT (ref https://lxr.openwrt.org/source/ubus/ubusmsg.h#L121).

The most likely cause is the nginx ubus plug-in adding an ubus_rpc_session string argument into the original call arguments object. Is your service maybe rejecting this unexpected argument? Is ubus call yourservice method '{ "ubus_rpc_session": "000000000000000000000000000000000000", "some": [ "other", "args" ] }' working?

Another potential reason is your HTTP call already containing an ubus_rpc_session argument. This is rejected for security reasons to prevent impersonating other sessions (the ubus HTTP gateway will inject this parameter automatically, inferring the effective session id from the authentication).

Thanks @jow ! The issue was the nginx-ubus adding that ubus_rpc_session, while my service is not defining it in the args of each method. So ubus was rejecting it as "wrong arguments" of course.

Now the ubus_rpc_session is listed as arg of each of my methods (ubus -v list ...), but it does work in the cli anyway without that arg so that's alright.

Thanks also for the link to the status code enum!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.