reconnect on failure
This commit is contained in:
parent
5f99248fd2
commit
0c7b28ecae
@ -248,11 +248,11 @@ void NymeaConnection::onError(QAbstractSocket::SocketError error)
|
|||||||
|
|
||||||
if (!m_currentTransport) {
|
if (!m_currentTransport) {
|
||||||
// We're trying to connect and one of the transports failed...
|
// We're trying to connect and one of the transports failed...
|
||||||
qDebug() << "A transport error happened for" << transport->url() << error << "(Still trying on" << m_transportCandidates.count() << "connections)";
|
|
||||||
if (m_transportCandidates.contains(transport)) {
|
if (m_transportCandidates.contains(transport)) {
|
||||||
m_transportCandidates.remove(transport);
|
m_transportCandidates.remove(transport);
|
||||||
transport->deleteLater();
|
transport->deleteLater();
|
||||||
}
|
}
|
||||||
|
qDebug() << "A transport error happened for" << transport->url() << error << "(Still trying on" << m_transportCandidates.count() << "connections)";
|
||||||
if (m_transportCandidates.isEmpty()) {
|
if (m_transportCandidates.isEmpty()) {
|
||||||
m_connectionStatus = errorStatus;
|
m_connectionStatus = errorStatus;
|
||||||
emit connectionStatusChanged();
|
emit connectionStatusChanged();
|
||||||
@ -283,6 +283,7 @@ void NymeaConnection::onConnected()
|
|||||||
// However, in practice it turns out there are too many issues for this to be reliable
|
// However, in practice it turns out there are too many issues for this to be reliable
|
||||||
// So lets just tear down any alternative connection that comes up again.
|
// So lets just tear down any alternative connection that comes up again.
|
||||||
|
|
||||||
|
qDebug() << "Dropping alternative connection again...";
|
||||||
m_transportCandidates.remove(newTransport);
|
m_transportCandidates.remove(newTransport);
|
||||||
newTransport->deleteLater();
|
newTransport->deleteLater();
|
||||||
|
|
||||||
@ -312,6 +313,16 @@ void NymeaConnection::onDisconnected()
|
|||||||
m_transportCandidates.remove(t);
|
m_transportCandidates.remove(t);
|
||||||
}
|
}
|
||||||
t->deleteLater();
|
t->deleteLater();
|
||||||
|
|
||||||
|
if (!m_currentTransport && m_transportCandidates.isEmpty()) {
|
||||||
|
qDebug() << "Last connection dropped. Trying to reconnect..";
|
||||||
|
QTimer::singleShot(1000, this, [this](){
|
||||||
|
if (m_currentHost) {
|
||||||
|
connectInternal(m_currentHost);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_transportCandidates.remove(m_currentTransport);
|
m_transportCandidates.remove(m_currentTransport);
|
||||||
|
|||||||
Reference in New Issue
Block a user