Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt process cannot receive signals sent by dbus-send



  • Re: QtDBus com::blah::test Interface fails to receive dbus-send signals and unittest signals

    Hello,

    My project is based on the Qt framework and basically consists in several processes communicating via DBus.
    The system I use:
    Qt 5.8
    Ubuntu 14.04 (imposed by the project context, I cannot move to a newer version)

    In order to implement some unit tests, I'm looking at how to send DBus messages via command line to implement some test scripts in the end.
    I've tested three packages: dbus-send, qdbus, and gdbus.

    There is no issue in calling methods exposed by my Qt processes DBus interfaces.
    Below is an example of the commands I use to call a method boolean isTrue() exposed by the interface org.company.processname (object /org/company/processname) using each of the three packages listed above:

    • dbus-send:
    dbus-send --system dest=org.company.processname  --type=method_call --print-reply /org/company/processname org.company.processname.isTrue
    
    • qdbus:
    qdbus --system --type=method --literal org.company.processname /org/company/processname org.company.processname.isTrue
    
    • gdbus:
    gdbus call --system --dest org.company.processname --object-path /org/company/processname --method org.company.processname.isTrue
    

    Each of these three calls returns the boolean value returned in the processname_adaptor.cpp.

    However, I can't emit signals that would be correctly received by my Qt processes.

    Below are the tentatives I've made using these three packages:

    • dbus-send:
    dbus-send --system --type=signal --print-reply /org/company/processname org.company.processname.signalname
    
    • qdbus:
      I've tried several typo (that did not work) but I'm not even sure the qdbus cmd allows sending signals, there is no mention in the man (https://helpmanual.io/help/qdbus/), all mentions are about methods...
      I've tested for instance this:
    qdbus --system --type=signal --literal org.company.processname /org/company/processname org.company.processname.signalname
    

    But I got an error that makes me think signals cannot be emitted by the cmd qdbus:

    Error: org.freedesktop.DBus.Error.UnknownMethod
    No such method 'signalname' in interface 'org.company.processname' at object path '/org/company/processname' (signature '')
    
    • gdbus:
    gdbus emit --system -o /org/company/processname -s org.company.processname.signalname
    

    In all cases (except using qdbus), when sniffing the system bus via

    dbus-monitor --system
    

    I see the same trace as when the signal is directly emitted by my Qt process (only the sender ID and the serial number differ):

    signal sender=:1.380 -> dest=(null destination) serial=2 path=/org/company/processname; interface=org.company.processname; member=signalname
    

    Yet, when the signal is emitted by my Qt process B and my other Qt process A connects to it, it can receive it. When the signal B::signalname is emitted via cmd line, A's slot is not called.

    My issue is extremely similar to sayo9394's in his post here https://forum.qt.io/topic/105003/qtdbus-com-blah-test-interface-fails-to-receive-dbus-send-signals-and-unittest-signals (which has no reply unfortunately).
    Indeed, when replacing the service name and object path by empty strings when connecting to the signal emitter's interface (process B) from the signal receiver (process A), A can receive signals sent by cmd line, but

    • the interface B instantiated in A is invalid (when calling QDBusAbstractInterface.isValid())
    • A cannot call B's methods anymore via Dbus (at least B's adaptor is not called)
    • I suppose putting empty strings makes A opened to any signal sent by any process, which is not desirable

    After all this explanation, my questions:

    • am I using the cmds wronly?
    • is there a bug in Qt framework that makes it unable to catch signals emitted by cmd line?
    • is cmd qdbus able to send signals, and could you please give me an example?

    Many thanks in advance for your help!
    Cheers,
    Cécile


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    While I understand your projects constraints, did you test it with a more recent version of Qt just to determine if this is something that changed in between ?



  • Hi, thank you for your reply!

    I compiled Qt 5.14 from sources (no package available for Ubuntu 14.04), and recompiled my project with Qt 5.14.
    I did the same tests I described in my first message and got the same results unfortunately...

    According to what you know about D-bus and sending messages via cmd line, do you think there is something wrong in my use of dbus-send/qdbus/gdbus?

    Do you know if qdbus is supposed to be used to send signals also (not only methods)?

    Thank you,
    Cécile


  • Lifetime Qt Champion

    Sorry I am not enough versed with DBus.

    I would recommend bringing that question to the interest mailing list. You'll find there the QtDBus maintainer.


Log in to reply