libamxb standalone client returns object_not_found on ubus: a reproducible pitfall
Grow through practice
No need to finish reading — test nowThis is not an “officially confirmed bug” — it is a reproducible field report.
ubus callworks, but a standalonelibamxbclient cannot find the object. If you integrate AMX, you may hit the same pitfall.
Symptom
amxrtregisters the object on ubus correctly;ubus listshowsHello;ubus call Hello _getreturns the object;- in a standalone C client,
amxb_connectreturns 0, butamxb_get/amxb_callreturn 2 (amxd_status_object_not_found).
Environment
| Component | Version |
|---|---|
| OS | Ubuntu 22.04 x86_64 |
| amxrt | v2.6.1 |
| libamxb | v4.17.2 |
| amxb_ubus | v3.11.1 |
| ubus | git 414c60a |
Local make builds installed under /usr; backend at /usr/bin/mods/amxb/mod-amxb-ubus.so.
Server side (works)
hello.odl:
%config {
name = "hello";
}
%define {
object Hello {
string Greeting = "Hello, AMX";
uint32 Count = 0;
}
}
Start:
ubusd -s /var/run/ubus/ubus.sock
amxrt -N \
-u ubus:/var/run/ubus/ubus.sock \
-B /usr/bin/mods/amxb/mod-amxb-ubus.so \
hello.odl
Verify:
$ ubus -s /var/run/ubus/ubus.sock list
Hello
$ ubus -s /var/run/ubus/ubus.sock call Hello _get
{
"Hello.": {
"Count": 0,
"Greeting": "Hello, AMX"
}
}
Client side (fails)
#include <stdio.h>
#include <unistd.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_types.h>
#include <amxb/amxb.h>
int main(void) {
amxb_bus_ctx_t* ctx = NULL;
amxc_var_t ret;
int rc;
rc = amxb_be_load("/usr/bin/mods/amxb/mod-amxb-ubus.so");
printf("be_load=%d\n", rc);
rc = amxb_connect(&ctx, "ubus:/var/run/ubus/ubus.sock");
printf("connect=%d\n", rc);
amxc_var_init(&ret);
rc = amxb_get(ctx, "Hello.", 0, &ret, 5);
printf("get(Hello.)=%d\n", rc);
if (rc == 0) amxc_var_dump(&ret, STDOUT_FILENO);
amxc_var_clean(&ret);
rc = amxb_call(ctx, "Hello.", "_get", NULL, &ret, 5);
printf("call(Hello.,_get)=%d\n", rc);
amxb_disconnect(ctx);
return 0;
}
Build:
cc repro.c -lamxb -lamxd -lamxp -lamxc -luriparser -lpthread -o repro
Measured:
be_load=0
connect=0
get(Hello.)=2
call(Hello.,_get)=2
What was tried
- URIs:
ubus:,ubus:/var/run/ubus/ubus.sock,ubus:///var/run/ubus/ubus.sock— all connect with 0; - paths:
Hello.,Hello,Hello.Greeting— all return 2; amxb_be_loadis called beforeamxb_connect;- the backend
.sois the same one the server-sideamxrtuses.
Suspect (not confirmed)
amxb_ubus_get_longest_path() builds a path and calls ubus_lookup_id(). It may be:
- passing a path with a trailing dot;
- or the standalone client needs a local DM / root / access context.
I did not change the code; the repro is documented first.
Workaround
Use the ubus CLI to read the object, or avoid the standalone libamxb client path. In our demo, hello-client uses ubus call; the server-side amxrt registers the object fine.
Why it is worth writing down
ubus callsucceeds whileamxb_getfails, which makes people suspect their ODL/backend;- versions, URIs and paths were all tried, so others can rule them out quickly;
- if maintainers confirm a bug, this is a minimal repro; if it is a usage requirement, it belongs in the docs.
One sentence
ubusworking does not mean thelibamxbclient works. Verify the object withubus callfirst, then debug the client path.
Related: Integrating Ambiorix into Yocto · Runnable demo
Comments 0
No comments yet — be the first!