I've got a QDbus communication set up that calls a method on the server side. It works for most requests, but not if the request processing time is higher than the default QDbus timeout of 25 seconds (I have tried with different processing times). One of my request needs around 40 seconds to process: the prepareDataMethod called runs until the end, but the request call returns a NoReply error after the default timeout.
The error message:
Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
I have set the interface timeout to 1 minute (and more), but this timeout seems to be ignored and each time the call will fail at around 25 seconds with the same error. No change either when trying with a shorter timeout (e.g. 1 second).
Client-side call to the method:
QDBusReply<T> reply;
QDBusInterface interface(service, path, "", QDBusConnection::systemBus());
if (interface.isValid()) {
interface.setTimeout(60000);
reply = interface.call(prepareDataMethod, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
if (!reply.isValid()) {
// print reply.error().message()
}
}
The method that I call on the server side with the body replaced by a sleep for testing purposes:
void prepareDataMethod() {
QEventLoop loop;
QTimer t;
t.connect(&t, &QTimer::timeout, &loop, &QEventLoop::quit);
t.start(TIMEOUT);
// TIMEOUT=20000 => works, TIMEOUT=40000 => NoReply
loop.exec();
}
I have also tried to increase the timeout with an asynchronous call:
QDBusPendingReply<T> reply = interface.asyncCall(
prepareDataMethod, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
reply.waitForFinished();
or using the QDBusConnection directly:
QDBusMessage request = QDBusMessage::createMethodCall(
service, path, "", prepareDataMethod);
reply = QDBusConnection::systemBus().call(request, mode, 60000);
with mode
= QDBus::Block
or QDBus::BlockWithGui
.
None of these seem to change the timeout for the call to return.