[Interest] Http Proxy connection woes

Jason Kretzer Jason at gocodigo.com
Tue Feb 24 22:24:24 CET 2015


Here is the thing:

I have software that is generally “proxy aware.”  I have it running behind other proxies and they seem to work.  The software is now running behind another proxy and I cannot seem to connect to the outside world using it.

Here is the code in main.cpp:
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(hostName);
proxy.setPort(port);
proxy.setUser(uname);
proxy.setPassword(pw);
QNetworkProxy::setApplicationProxy(proxy);

I have validated with the client that it is an HttpProxy.  I have left out how I get the settings, but they are accurate and in the proper format.  The uname/pw are windows authentication and I tried it with both “adomain\bob” and “bob at domain.com”.

After the proxy is set above the application goes on its merry way.
Eventually, I need to see if I have network access and do this in a separate file(not main.cpp):

ServerCommunication().connectToPort(hostName,port);

//here is the code for that function
bool ServerCommunication::connectToPort(QString server, int port)
{
    QTcpSocket socket;
    socket.connectToHost(server,port);
    if(socket.waitForConnected(500)) {
        qDebug() << "Connect to Host success!";
        socket.close();
        return true;
    }
    qDebug() << "ConnectToHost Error String: " << socket.errorString();
    socket.close();
    return false;
}


It may not be the best way to check for access but that is a different thing.

Anyway, when it runs, this line —  qDebug() << "ConnectToHost Error String: " << socket.errorString();
Prints:
DEBUG: ConnectToHost Error String:  "Error communicating with HTTP proxy”


Just as an extra piece of information, I also tried it with a SOCKS5 ProxyType and the line printed:
DEBUG: ConnectToHost Error String:  "Socket operation timed out"

Is there some obvious thing I am missing here?

-Jason

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150224/75b855e6/attachment.html>


More information about the Interest mailing list