Problem with inter-snap dbus method calls

I am looking for some help with an issue I have encountered with using the dbus in snaps.

I have created a snap (gozer-server-snap) which has a GO app (gozer-server) that runs as a daemon process that creates a new named connection (com.yyz2112.gozer) on the system bus and exposes several methods that are to be called from client snaps. Inside this same snap I created another GO app (gozer-client) that connects to that named connection on the system dbus and then calls the daemon methods and receives signals from the daemon. It is exposed as a snap command/app. I have installed this snap, the daemon runs and the client app connects and runs fine.

Then I created a separate client snap (gozer-client-snap) that has the same client app (gozer-client) installed and configured exactly the same as above, but when I run the app command it always gives me the following error:

$gozer-client-snap.gozer-client

panic: An AppArmor policy prevents this sender from sending this message to this recipient; type=“method_call”, sender=":1.98" (uid=1000 pid=32567 comm="/snap/gozer-client-snap/35/bin/gozclient " label=“snap.gozer-client-snap.gozer-client (enforce)”) interface="(unset)" member=“WriteData” error name="(unset)" requested_reply=“0” destination=“com.yyz2112.gozer” (uid=0 pid=29738 comm="/snap/gozer-server-snap/2/bin/server " label=“snap.gozer-server-snap.gozer-server (enforce)”)

I have created the exact same plug definitions in both snaps, manually connected both dbus plug-slot connections in both snaps, and the applications install the exact same binary.

> $ snap connections | grep gozer
> dbus      gozer-server-snap:dbus-svc     gozer-server-snap:dbus-daemon            -
> dbus      gozer-client-snap:dbus-svc     gozer-server-snap:dbus-daemon            manual

However, the “internal” (gozer-server-snap) command works but not the “external” one (gozer-client-snap).

Does anyone have any thoughts of what the issue might be or how to fix? I have included the relevant parts of both snapcraft.yaml files below.

Thanks!

gozer-server-snap:

name: gozer-server-snap 
base: core18 
version: '0.1' 
summary: Go daemon
description:  This is my-snap's description.
grade: stable
confinement: strict

slots:
  dbus-daemon:
    interface: dbus
    bus: system
    name: com.yyz2112.gozer

plugs:
  dbus-svc:
    bus: system
    interface: dbus
    name: com.yyz2112.gozer

apps:
  gozer-server:
    command: bin/server
    daemon: simple
    plugs:
      - hardware-observe
      - serial-port
    slots: [ dbus-daemon ]

  gozer-client:
    command: bin/gozclient
    plugs: 
      - dbus-svc

gozer-client-snap:

name: gozer-client-snap
base: core18 
version: '1.0' 
summary: test client
description:  test client
grade: stable
confinement: strict

plugs:
  dbus-svc:
    bus: system
    interface: dbus
    name: com.yyz2112.gozer

apps:
  gozer-client:
    command: bin/gozclient
    plugs:
      - dbus-svc

can you please provide the output of

sudo aa-status

with server and client running

Another piece of information that would be good to attach is the apparmor profiles for gozer. You will find them in /var/lib/snapd/apparmor/profiles/

It’d also be useful to know the object path and interface you’re using for the failing method call.

I’ve created a proof-of-concept for using dbus to connect two snaps:

This has a Go-based “server” snap and a python-based client. I found that the key to getting everything working was to make sure the object path and interface in the applications lines up with the declarations in the snapcraft.yaml files.