Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setApplicationProxy and QNetworkAccessManager proxyAuthenticationRequired
Forum Updated to NodeBB v4.3 + New Features

setApplicationProxy and QNetworkAccessManager proxyAuthenticationRequired

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GBergamo
    wrote on last edited by
    #1

    Hi,
    I am using Qt 5.5.1.
    If I set the global proxy settings with the static method setApplicationProxy (with username and password) everything works as expected, except some times when, after some hours of "good" http posts thru the proxy, I get the proxyAuthenticationRequired error from the QNetworkAccessManager object that I use for making the requests.
    The proxy is a squid 3 with digest authentication.
    It seems like Qt is loosing the credentials that I set with setApplicationProxy...is this a normal behavior? Must I refill the credentials in the proxyAuthenticationRequired slot using the authenticator object?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I'm by no way specialist but doesn't the squid have a validity interval for the digest ? If so you're likely hitting that value and must generate a new one providing again your credentials.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GBergamo
        wrote on last edited by
        #3

        Thank you for the answer.
        Yes it could be...but what is strange to me is that when the proxyAuthenticationRequired signal arrives, if I retrieve the application proxy settings by calling the static method "applicationProxy" inside the returned QNetworkProxy object I can find the right credentials (username and password are still the one I've set with setApplicationProxy).
        I had a look at the qnetworkaccessmanager code and it seems that, before firing the signal, it tries to get the "cached" credentials (using fetchCachedProxyCredentials) but it does not look at the credential set using setApplicationProxy...this could be a bug IMHO.
        Otherwise I'd like to understand if this is a wanted behavior.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          AFAIK, fetchCachedProxyCredentials gets the application proxy if you are using the default proxy.

          Can you share how you setup your QNetworkAccessManager and your squid proxy ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GBergamo
            wrote on last edited by
            #5

            Thank you for your time.
            BTW I've soved the problem.
            Now in the proxyAuthenticationRequired slot of the QNetworkAccessManager object I get the global proxy settings object and I set username and password in the authenticator object passed to the slot.
            It seems to work and when it happens I see messages like these:

            QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://xxxx@xxxxxxx.xxxx:80#TestSquidProxy' (access/qnetworkaccesscache.cpp:255, void QNetworkAccessCache::addEntry(const QByteArray&, QNetworkAccessCache::CacheableObject*))

            QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://xxxx@xxxxxxx.xxx:80' (access/qnetworkaccesscache.cpp:255, void QNetworkAccessCache::addEntry(const QByteArray&, QNetworkAccessCache::CacheableObject*))

            QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://xxxxxxx.xxx:80' (access/qnetworkaccesscache.cpp:255, void QNetworkAccessCache::addEntry(const QByteArray&, QNetworkAccessCache::CacheableObject*))

            So it seems it was something related to cached credentials.
            Thank you for your help.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved