Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/qamqpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void QAmqpClientPrivate::_q_connect()
if (socket->state() != QAbstractSocket::UnconnectedState) {
qAmqpDebug() << Q_FUNC_INFO << "socket already connected, disconnecting..";
_q_disconnect();
socket->abort();
}

qAmqpDebug() << "connecting to host: " << host << ", port: " << port;
Expand Down
36 changes: 36 additions & 0 deletions tests/auto/qamqpclient/tst_qamqpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private Q_SLOTS:
void validateUri();
void issue38();
void issue38_take2();
void networkDownThenUp();

public Q_SLOTS: // temporarily disabled
void autoReconnect();
Expand Down Expand Up @@ -305,6 +306,41 @@ void tst_QAMQPClient::issue38_take2()
QVERIFY(waitForSignal(&client,SIGNAL(disconnected())));
}

void tst_QAMQPClient::networkDownThenUp()
{
QAmqpClient client;
client.setHost("localhost"); // this should be changed to your server OTHER THAN localhost, as we test the network connection down and up
client.setPort(5672);
client.setVirtualHost("/");
client.setUsername("guest");
client.setPassword("guest");
client.setAutoReconnect(false);
client.connectToHost();
QVERIFY(waitForSignal(&client, SIGNAL(connected())));
qDebug() << "Connection connected";

int i = 10; // during the 5 minutes test, please disable the ethernet connection and enabled it mannualy.

while (i > 0) {
client.disconnectFromHost();
if (waitForSignal(&client,SIGNAL(disconnected()))) {
qDebug() << "Connection disconnected";
} else {
qDebug() << "Disconnect timeout";
}

client.connectToHost();
if (waitForSignal(&client, SIGNAL(connected()))) {
qDebug() << "Connection connected";
} else {
qDebug() << "Connection timeout";
}

QTest::qSleep(30000);

i--;
}
}

QTEST_MAIN(tst_QAMQPClient)
#include "tst_qamqpclient.moc"