[Interest] Http Proxy connection woes

Thiago Macieira thiago.macieira at intel.com
Mon Apr 6 17:47:59 CEST 2015


On Monday 06 April 2015 07:52:01 Jason Kretzer wrote:
> bool ServerCommunication::connectToPort(QString server, int port)
> {
>     QTcpSocket socket;
>     QNetworkProxy proxy = QNetworkProxy::applicationProxy();
>     socket.setProxy(proxy);

These two lines are unnecessary. QTcpSocket will use the application proxy by 
default.

> void ServerCommunication::onProxyAuthenticationRequired(const QNetworkProxy
> &p, QAuthenticator *auth) {
>     qDebug() << "Calling onProxyAuthenticationRequired method";
>     QNetworkProxy proxy = QNetworkProxy::applicationProxy();
>     auth->setUser(proxy.user());
>     auth->setPassword(proxy.password());
> }

Given what the proxy you've set in the first method, you're not adding any new 
information here. Your proxy user and/or password are incorrect or missing in 
QNetworkProxy::applicationProxy() in the first place.

> I am totally at a loss on this.  I have googled this for hours looking for
> different ideas.  Would using a QNetworkAccessManager fare any better than
> the QTcpSocket?   Am I using the Qauthenticator correctly?  Should I
> further increase the timeout?  Do I need to disconnect the SIGNAL from
> inside the SLOT to keep it from being called so many times — ie. Is that
> resetting the progress and never allowing it to properly authenticate?

Your code is correct, even if it does things it doesn't have to.

The problem is that your authentication credentials are wrong.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list