From 0dba5ef33ef4dfdddb50c8359ac636da19e000d4 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 16 Dec 2021 14:56:52 +0100 Subject: [PATCH] Don't wait for all transport candidates to fail before retrying --- libnymea-app/connection/nymeaconnection.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libnymea-app/connection/nymeaconnection.cpp b/libnymea-app/connection/nymeaconnection.cpp index f7cb6a73..8a665ddf 100644 --- a/libnymea-app/connection/nymeaconnection.cpp +++ b/libnymea-app/connection/nymeaconnection.cpp @@ -71,10 +71,10 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent) updateActiveBearers(); - m_reconnectTimer.setInterval(1000); + m_reconnectTimer.setInterval(500); m_reconnectTimer.setSingleShot(true); connect(&m_reconnectTimer, &QTimer::timeout, this, [this](){ - if (m_currentHost) { + if (m_currentHost && !m_currentTransport) { qCInfo(dcNymeaConnection()) << "Reconnecting..."; connectInternal(m_currentHost); } @@ -249,13 +249,14 @@ void NymeaConnection::onError(QAbstractSocket::SocketError error) foreach (Connection *c, m_transportCandidates) { qCDebug(dcNymeaConnection()) << "Connection candidate:" << c->url(); } + + if (m_connectionStatus != ConnectionStatusSslUntrusted && !m_reconnectTimer.isActive()) { + m_reconnectTimer.start(); + } + if (m_transportCandidates.isEmpty()) { m_connectionStatus = errorStatus; emit connectionStatusChanged(); - - if (m_connectionStatus != ConnectionStatusSslUntrusted) { - m_reconnectTimer.start(); - } } } }