Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29556

QAbstractSocket::error signal is not emitted whena connection to SOCKS5 proxy times out

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.5.3, 4.8.3, 5.0.1
    • Network: Proxies
    • None
    • Tested on: Qt 5.0.1, Qt 4.8.3, Qt 4.5.3; probably all Qt 4.5+ are affected.

      Linux sjinks 3.5.0-22-generic #34-Ubuntu SMP Tue Jan 8 21:47:00 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 12.10)

    Description

      // See http://stackoverflow.com/a/904609/1046773
      QHostAddress unrouteable(QLatin1String("255.255.255.0"));
      
      QTcpSocket sock;
      QSignalSpy spy(&sock, SIGNAL(error(QAbstractSocket::SocketError)));
      
      QNetworkProxy proxy;
      proxy.setType(QNetworkProxy::Socks5Proxy);
      proxy.setHostName(unrouteable.toString());
      proxy.setPort(65000);
      sock.setProxy(proxy);
      
      QObject::connect(&sock, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
      
      sock.connectToHost(QLatin1String("msn.com"), 80); // address and port do not matter here
      
      // QT_CONNECT_TIMEOUT is 30 s, QAbstractSocket makes two connection attempts; add 1 minute more just to be safe.
      QTestEventLoop::instance().enterLoop(60 + 60);
      
      QVERIFY(spy.count() == 1); // Fails in Qt 4.5+; error() is never emitted
      
      QVariantList res = spy.takeFirst();
      #if QT_VERSION >= 0x040500
      QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(res.at(0)), QAbstractSocket::ProxyConnectionTimeoutError);
      #else
      QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(res.at(0)), QAbstractSocket::ConnectionRefusedError);
      #endif
      

      Expected result: when proxy connection times out, error() signal should be emitted (just like in Qt 4.2 where this works).

      Actual result: proxy connection times out silently, neither error() nor disconnected() nor stateChanged() signals are emitted.

      Attachments

        1. 29556.diff
          0.5 kB
        2. proxytest.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shkearns Shane Kearns
            vladimir.kolesnikov Vladimir Kolesnikov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes