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 ja...@gocodigo.com<mailto:ja...@gocodigo.com> //------------------------------// “quidquid latine dictum sit altum videtur"
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest