← All posts

libamxb standalone client returns object_not_found on ubus: a reproducible pitfall

Grow through practice

No need to finish reading — test now

This is not an “officially confirmed bug” — it is a reproducible field report. ubus call works, but a standalone libamxb client cannot find the object. If you integrate AMX, you may hit the same pitfall.

Symptom

  • amxrt registers the object on ubus correctly;
  • ubus list shows Hello;
  • ubus call Hello _get returns the object;
  • in a standalone C client, amxb_connect returns 0, but amxb_get / amxb_call return 2 (amxd_status_object_not_found).

Environment

ComponentVersion
OSUbuntu 22.04 x86_64
amxrtv2.6.1
libamxbv4.17.2
amxb_ubusv3.11.1
ubusgit 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_load is called before amxb_connect;
  • the backend .so is the same one the server-side amxrt uses.

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 call succeeds while amxb_get fails, 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

ubus working does not mean the libamxb client works. Verify the object with ubus call first, then debug the client path.


Related: Integrating Ambiorix into Yocto · Runnable demo

Practice

Found this useful?

I write about AI agents × embedded / edge AI. Subscribe, or email me a concrete problem.

Guestbook →Subscribe (RSS)Support

Comments 0

No comments yet — be the first!

No login required; name is optional.