[Interest] Odd Proxy Behavior

Jason Kretzer Jason at gocodigo.com
Tue Nov 29 18:34:32 CET 2016


Typically, this code just works.  Ever since implementing it, I have had no issues at all when putting a device behind a network proxy — both HttpProxy and HttpCachingProxy.  Unfortunately, it is not working for a particular HttpProxy.

Here is the code:

    qDebug() << "Detecting Proxy Settings";
    QNetworkProxyQuery npq(QUrl("http://www.google.com"));
    QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
    qDebug() << "LIST OF PROXIES SIZE: "<< listOfProxies.size();
    qDebug() << "\n=====================\n";
    for(int i=0; i< listOfProxies.size(); i++) {
        qDebug() << "Proxy Type: " << listOfProxies[i].type();
        qDebug() << "Proxy hostname:" << listOfProxies[i].hostName();
        qDebug() << "Proxy port: " << listOfProxies[i].port();
        qDebug() << "Is Caching Proxy? " << listOfProxies[i].isCachingProxy();
        qDebug() << "Is Transparent Proxy? " << listOfProxies[i].isTransparentProxy();
        qDebug() << "\n=====================\n";
    }
    if(listOfProxies.size() > 0) {
        QNetworkProxy::setApplicationProxy(listOfProxies[0]);
    } else {
        QNetworkProxyFactory::setUseSystemConfiguration(true);
    }

Here is the output:
[16:27:13]: DEBUG: Detecting Proxy Settings
[16:27:13]: DEBUG: LIST OF PROXIES SIZE:  1
[16:27:13]: DEBUG:
=====================

[16:27:13]: DEBUG: Proxy Type:  3
[16:27:13]: DEBUG: Proxy hostname: “proxy"
[16:27:13]: DEBUG: Proxy port:  8080
[16:27:13]: DEBUG: Is Caching Proxy?  true
[16:27:13]: DEBUG: Is Transparent Proxy?  true
[16:27:13]: DEBUG:
=====================


Shortly after the code above is executed, I preform a GET function against a certain url:
NOTE: the url is accessible via a browser, so it is not being blocked.

QJsonDocument ServerCommunication::executeGET(QUrl url)
{
    QNetworkReply* reply = _manager->get(QNetworkRequest(url));
    qDebug() << "EXECUTEGET -- " << url.toDisplayString();
    // Wait for the manager get function to finish
    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    if(!reply->isFinished())
        loop.exec();
    QByteArray bytearray = reply->readAll();
    if(bytearray.isNull() || bytearray.isEmpty()) {
        qDebug() << "reply to GET ("+url.toString()+") is null or empty.";
    } else {
        qDebug() << "Successful GET("+url.toString()+")";
    }
    return QJsonDocument::fromJson(bytearray);
}

In the middle there, the loop.exec() starts executing and never finishes.  There are no credentials required for this proxy.

The device this runs on is on a client’s network and I have no access to anything other than the device.  I have requested that the client change the proxy hostname to the ip address or fqdn but I am not sure whether that will help.

Further information:
Qt5.5.1 – 32bit
OS – Windows Embedded Standard (7)

Thoughts?

-Jason

//------------------------------//
   Jason R. Kretzer
   Lead Application Developer
   Jason at gocodigo.com<mailto:Jason at gocodigo.com>
//------------------------------//

“quidquid latine dictum sit altum videtur"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161129/4c74c251/attachment.html>


More information about the Interest mailing list